问题标题:
SQL语句casewhenselecttrunc(date'2009-01-01','dd')asdate_id,b.org_idasorg_id,b.risk_idasrisk_id,sum(a.planfee-nvl(c.payreffee,0)),(casewhento_char(statistic_date-payrefdate>=0)andto_char(st
更新时间:2024-04-28 01:37:13
问题描述:

SQL语句casewhen

select trunc(date'2009-01-01','dd')asdate_id, b.org_idasorg_id, b.risk_idasrisk_id, sum(a.planfee-nvl(c.payreffee,0)), (casewhento_char(statistic_date-payrefdate>=0)andto_char(statistic_date-payrefdate<90)thensum(a.planfee-nvl(c.payreffee,0)) else''end), (casewhento_char(statistic_date-payrefdate>=90)andto_char(statistic_date-payrefdate<180)thensum(a.planfee-nvl(c.payreffee,0)) else''end), (casewhento_char(statistic_date-payrefdate>=180)andto_char(statistic_date-payrefdate<360)thensum(a.planfee-nvl(c.payreffee,0)) else''end), (casewhento_char(statistic_date-payrefdate>=360)andto_char(statistic_date-payrefdate<720)thensum(a.planfee-nvl(c.payreffee,0)) else''end), (casewhento_char(statistic_date-payrefdate>=720)thensum(a.planfee-nvl(c.payreffee,0))else''end) fromdm_f_prpjplanfee_propa,dm_policy_prop_cntb,(selectcertino,serialno,sum(payreffee)aspayreffeefromdm_f_prpjpayrefrec_propwherepayrefdate<=(date'2009-01-31')groupbycertino,serialno) cwhere a.certino=b.endorse_no anda.certino=c.certino(+)anda.serialno=c.serialno(+)and notexists(select1 fromdm_policy_prop_cnt whereb.policy_no=policy_no andendorse_type_code='19' andcerti_type='E' andstatistic_date<=date '2009-01-31') --andb.policy_no='605012008110000000741' andb.statistic_date<=date '2009-01-31'groupbytrunc(date'2009-01-31','dd'),b.org_id,b.risk_id 这是一个SQL里面的casewhen语句,如果执行这个语句,会提示缺少右括号,但如果把casewhen语句去掉,就可以执行这个语句.

何凤有回答:
  太长了,但是看到一个问题,casewhen,要求返回的类型必须一直.   你看你的第一个casewhen语句   (casewhento_char(statistic_date-payrefdate>=0)andto_char(statistic_date-payrefdate
其它推荐
热门其它推荐
首页
栏目
栏目
栏目
栏目