太長了,但是看到一個問題,case when,要求返回的類型必須一直.
你看你的第一個case when語句
(case when to_char(statistic_date-payrefdate>=0) and to_char(statistic_date-payrefdate
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語句,如果執(zhí)行這個語句,會提示缺少右括號,但如果把case when語句去掉,就可以執(zhí)行這個語句.
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語句,如果執(zhí)行這個語句,會提示缺少右括號,但如果把case when語句去掉,就可以執(zhí)行這個語句.
其他人氣:756 ℃時間:2020-07-03 20:45:49
優(yōu)質(zhì)解答
我來回答
類似推薦
- sql語句 case when or
- i believe that that that that that student says is right.
- 薄煙的薄應(yīng)該怎么念?這個字的兩種讀音又該怎樣分辨?
- 一九七九年那是一個春天,有一個老人在中國南海邊……
- i used to think that i could not go on的手語
- 文言文題目【王充市肆博覽】
- 翻譯句子:如果明天下雨怎么辦?用What if.(另外,what if后面用陳述語序,必須用一般現(xiàn)在時態(tài)嗎?)
- 怎樣寫自然景觀
- 1、關(guān)漢卿元曲創(chuàng)作的藝術(shù)成就有哪些?2、在關(guān)漢卿寫的元曲中,哪一首元曲最能體現(xiàn)關(guān)漢卿的性格特征?
- 環(huán)丙烷與環(huán)丁烷與環(huán)戊烷與環(huán)己烷哪個更穩(wěn)定,為什么?
- 袋鼠是一種低級的哺乳動物嗎?為什么?
- dye-packs是什么意思
猜你喜歡
- 19分之8×10分之3 還有3分之1×4分之1還有6×12分之11
- 2用exercise和dress的適當形式填空 (請看問題補充)
- 3甲乙丙三位同學都喜歡集郵,甲有郵票18張,相當于乙的3/4,丙的郵票張數(shù)跟乙的張數(shù)的比恰好是2:3
- 4Everyone is busy() ready for Christmas A.to get B.getting C.got D.gets
- 5函數(shù)不能嵌套定義是什么意思
- 6幫忙解答下《假如你想做一株臘梅》有關(guān)題目
- 7形容兩個人的感情幸福的四字成語
- 8某班7個興趣小組人數(shù)分別為3,3,4,x,5,6,已知這組數(shù)據(jù)的平均數(shù)是4,則這組數(shù)據(jù)的中位數(shù)是?
- 9東南亞的主要礦產(chǎn)和分布?
- 10根據(jù)所給的首字母提示,用合適的單詞填空,
- 11Could you tell me ___ with the money?A hou to do B what should I do C how should I do
- 12“小大之獄,雖不能察,必以情”與“忠之屬也”之間的內(nèi)在聯(lián)系是什么