资源描述:
《oracle中的casewhen用法》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、用来在一个表中,建立多条件的提炼,非常有用。单条件的提炼函数是decode(对照值,条件1,结果1,条件2,结果2……条件N,结果N,其他)createorreplaceviewv_card_channel_count5(icpcode,sumarea,count1201,count1202,count1203,count1204,count1205,count1206,count1207,count1208,count1209,count1210,count1211,count1212,count1213,count
2、1214,count1215,count1216,count1217,count1218,count1219,count1220,count1221,count1222,count1223,count1224,count1225,count1226,count1227,count1228,count1229,count1230,count1231)asselecticpcode,'当期订购数',sum(casewhento_char(subscribe_time,'dd')='01'thensubscribe_nume
3、lse0end),sum(casewhento_char(subscribe_time,'dd')='02'thensubscribe_numelse0end),sum(casewhento_char(subscribe_time,'dd')='03'thensubscribe_numelse0end),sum(casewhento_char(subscribe_time,'dd')='04'thensubscribe_numelse0end),sum(casewhento_char(subscribe_time,'d
4、d')='05'thensubscribe_numelse0end),sum(casewhento_char(subscribe_time,'dd')='06'thensubscribe_numelse0end),sum(casewhento_char(subscribe_time,'dd')='07'thensubscribe_numelse0end),sum(casewhento_char(subscribe_time,'dd')='08'thensubscribe_numelse0end),sum(casewhe
5、nto_char(subscribe_time,'dd')='09'thensubscribe_numelse0end),sum(casewhento_char(subscribe_time,'dd')='10'thensubscribe_numelse0end),sum(casewhento_char(subscribe_time,'dd')='11'thensubscribe_numelse0end),sum(casewhento_char(subscribe_time,'dd')='12'thensubscrib
6、e_numelse0end),sum(casewhento_char(subscribe_time,'dd')='13'thensubscribe_numelse0end),sum(casewhento_char(subscribe_time,'dd')='14'thensubscribe_numelse0end),sum(casewhento_char(subscribe_time,'dd')='15'thensubscribe_numelse0end),sum(casewhento_char(subscribe_t
7、ime,'dd')='16'thensubscribe_numelse0end),sum(casewhento_char(subscribe_time,'dd')='17'thensubscribe_numelse0end),sum(casewhento_char(subscribe_time,'dd')='18'thensubscribe_numelse0end),sum(casewhento_char(subscribe_time,'dd')='19'thensubscribe_numelse0end),sum(c
8、asewhento_char(subscribe_time,'dd')='20'thensubscribe_numelse0end),sum(casewhento_char(subscribe_time,'dd')='21'thensubscribe_numelse0end),sum(casewhento_char(subscri