数据库
首页 > 数据库> > oracel根据条件不同,统计数据sql

oracel根据条件不同,统计数据sql

作者:互联网

select count(case
               when ml_type = '00' then
                'gjml'
             end) gjml,
       count(case
               when ml_type = '32' then
                'jsml'
             end) jsml,
       count(case
               when use_level = '0' then
                'gjxs'
             end) gjxs,
       count(case
               when use_level = '01' then
                'sjxs'
             end) sjxs,
       count(case
               when use_level = '02' then
                'shijxs'
             end) shijxs,
       count(case
               when use_level = '03' then
                'xjxs'
             end) xjxs,
       count(case
               when use_level = '01,02,03' then
                'gtxs'
             end) gtxs
  from qzqd.T_CATALOG_MESSAGE t
 where 1 = 1
   and t.DATA_VALID_FLAG = '1'
   and STATE = '2'
   and YWTYPE != '3'

  

标签:case,count,use,end,统计数据,level,oracel,when,sql
来源: https://www.cnblogs.com/qxqbk/p/15263369.html