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=?



你可能感兴趣的:(oracle)