summing a plurality of different conditions oracle

SELECT
                         COUNT(CASE
                             WHEN category LIKE '%外购附件%' THEN 1
                         END) wgfjcount,
                         COUNT(CASE
                             WHEN category LIKE '%外购执行机构%' THEN 1
                         END) whzxjgcount,
                         COUNT(CASE
                             WHEN category LIKE '%外购阀门%' THEN 1
                         END) wgfmcount
                     FROM
                         pmp_task_orderno_purchase_p a
                     WHERE
                         a.orderno8 = ':orderNo8'
select
                         count(case when tech_Type = '外购件'  then 1 end ) wgjCount,
                         count(case when tech_Type = '标准件'  then 1 end ) bzjCount,
                         count(case when tech_Type = '毛坯外协件'  then 1 end ) mpwxjCount,
                         count(case when tech_Type = '外购附件'  then 1 end ) wgfjCount,
                         count(case when tech_Type = '外购执行机构'  then 1 end ) whzxjgCount,
                         count(case when tech_Type = '外购阀门'  then 1 end ) wgfmCount,
                         count(case when tech_Type like '%品牌接头%'  then 1 end ) ppCount,
                         count(case when tech_Type = '其他'  then 1 end ) otherCount
                        from
                        pmp_task_orderno_purchase_e a
                        where a.orderno8 = ':orderNo8'

 

Published 20 original articles · won praise 7 · views 6940

Guess you like

Origin blog.csdn.net/qq_41247642/article/details/104834452