阅读背景:

oracle一张表中实现多个字段的统计(多个count)

来源:互联网 

恰好在项目里看到,其实语句里面一下东西我还不理解,先记下来,有时间学习后再补充。

select
 count(case when  A_FSSJ1 >= trunc(sysdate,'month')  and A_FSSJ1 <=trunc(last_day(sysdate)) then 'un_deal' end) byfa,
 count(case when  A_FSSJ1 >= trunc(add_months(sysdate,-1),'month')  and A_FSSJ1 <=trunc(last_day(add_months(sysdate,-1)))   	then 'un_deal' end) hbfa,
 count(case when  A_FSSJ1 >= trunc(add_months(sysdate,-12),'month')  and A_FSSJ1 <=trunc(last_day(add_months(sysdate,-12))) 	then 'un_deal' end) tbfa 
from  case_qsaj where a_ajlb2=?
sele



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: