SQL语句case whenselect 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(st
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/15 18:46:01
SQL语句case whenselect 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(st
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语句去掉,就可以执行这个语句.
SQL语句case whenselect 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(st
太长了,但是看到一个问题,case when,要求返回的类型必须一直.
你看你的第一个case when语句
(case when to_char(statistic_date-payrefdate>=0) and to_char(statistic_date-payrefdate