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'

  

上一篇:[SQL] CASE...WHEN 进行排序和分组


下一篇:Redis内存溢出:OOM command not allowed when used memory > ‘maxmemory‘