SQL语句case when

SQL语句case when

题目
SQL语句case when
select    trunc(date '2009-01-01','dd') as date_id,          b.org_id as org_id,          b.risk_id as risk_id,          sum(a.planfee-nvl(c.payreffee,0)) ,          (case when to_char(statistic_date-payrefdate>=0) and to_char(statistic_date-payrefdate<90) then sum(a.planfee-nvl(c.payreffee,0))  else '' end),          (case when to_char(statistic_date-payrefdate>=90) and to_char(statistic_date-payrefdate<180) then sum(a.planfee-nvl(c.payreffee,0))  else '' end),          (case when to_char(statistic_date-payrefdate>=180) and to_char(statistic_date-payrefdate<360) then sum(a.planfee-nvl(c.payreffee,0))  else '' end),          (case when to_char(statistic_date-payrefdate>=360) and to_char(statistic_date-payrefdate<720) then sum(a.planfee-nvl(c.payreffee,0))  else '' end),          (case when to_char(statistic_date-payrefdate>=720) then sum(a.planfee-nvl(c.payreffee,0)) else '' end)          from dm_f_prpjplanfee_prop a,dm_policy_prop_cnt b,(select certino,serialno,sum(payreffee) as payreffee from dm_f_prpjpayrefrec_prop where payrefdate<=(date'2009-01-31') group by certino,serialno)  cwhere   a.certino=b.endorse_no  and a.certino=c.certino(+) and a.serialno=c.serialno(+)and     not exists (select 1                   from dm_policy_prop_cnt                  where b.policy_no = policy_no                    and endorse_type_code = '19'                    and certi_type = 'E'                    and statistic_date <= date  '2009-01-31')                    --and b.policy_no='605012008110000000741'                    and b.statistic_date <= date  '2009-01-31' group by trunc(date '2009-01-31','dd'),b.org_id,b.risk_id  这是一个SQL里面的case when语句,如果执行这个语句,会提示缺少右括号,但如果把case when语句去掉,就可以执行这个语句.
答案
太长了,但是看到一个问题,case when,要求返回的类型必须一直.
你看你的第一个case when语句
(case when to_char(statistic_date-payrefdate>=0) and to_char(statistic_date-payrefdate
举一反三
我想写一篇关于奥巴马的演讲的文章,写哪一篇好呢?为什么好
奥巴马演讲不用看稿子.为什么中国领导演讲要看?
想找英语初三上学期的首字母填空练习……
英语翻译
1,人们染上烟瘾,最终因吸烟使自己丧命.
最新试题
热门考点

超级试练试题库

© 2017-2019 超级试练试题库,All Rights Reserved.