码迷,mamicode.com
首页 > 其他好文 > 详细

使用count、rollup、case…when进行分类汇总统计

时间:2018-09-18 13:45:13      阅读:251      评论:0      收藏:0      [点我收藏+]

标签:统计   技术   code   com   char   to_date   分类   pre   sele   

 

 

Select nvl(to_char(a.create_date, ‘yyyy-mm-dd‘), ‘合计‘) 日期,
       count(case
               when a.flownode_code = ‘2‘ then
                a.work_id
             end) 工单分配,
       count(case
               when a.flownode_code = ‘1001‘ then
                a.work_id
             end) 测量,
       count(case
               when a.flownode_code = ‘1003‘ then
                a.work_id
             end) 外线
  From t_od_work a
 where a.flownode_code in (‘2‘, ‘1001‘, ‘1003‘)
   and a.create_date >= To_Date(‘2018-08-01‘, ‘yyyy-mm-dd‘)
   and a.create_date <= To_Date(‘2018-09-01‘, ‘yyyy-mm-dd‘)
 group by rollup(to_char(a.create_date, ‘yyyy-mm-dd‘))
 order by to_char(a.create_date, ‘yyyy-mm-dd‘);

 技术分享图片

 

使用count、rollup、case…when进行分类汇总统计

标签:统计   技术   code   com   char   to_date   分类   pre   sele   

原文地址:https://www.cnblogs.com/wzh313/p/9668285.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!