您的位置:首页 > 数据库 > Oracle

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

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

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=?
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: