oracle 多列求和

第一种:

select sum(decode(count1,null,0,count1) +decode(count2,null,0,count2)
+decode(count3,null,0,count3)) a from test_table

第二种:

select sum (case when count1 is not null then count1 when 
count2 is not null then count2 when count3 is not null 
then count3 else '0' end ) a from test_table

  

posted @ 2019-06-04 10:15  愚蠢的程序员  阅读(8998)  评论(0编辑  收藏  举报