ORACLE 按表字段值的不同统计数量

Posted lxjshuju

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ORACLE 按表字段值的不同统计数量相关的知识,希望对你有一定的参考价值。

select p.id comperitorId,p.compcorp competitorName,
sum(case when c.kindname = ‘ATM‘ then c.num else 0 end)  atm,
sum(case when c.kindname = ‘CRS‘ then c.num else 0 end)  crs,
sum(case when c.kindname = ‘VTM‘ then c.num else 0 end)  vtm,
sum(case when c.kindname = ‘清分机‘ then c.num else 0 end) sorter,
sum(case when c.kindname = ‘软件‘ then c.num else 0 end) software,
sum(case when c.kindname = ‘其他‘ then c.num else 0 end) other,
m.iscommunication iscommunication
from compproduct c 
join competitor p on c.competitor_id=p.id 
join (select f.custid,t.companyid,t.iscommunication from technologycompany t join technology_flow f on f.id=t.flowid) m on c.competitor_id=m.companyid and c.cust_id=m.custid 
where c.cust_id=‘7649‘ 
group by p.id,c.competitor_id,p.compcorp,m.iscommunication 


以上是关于ORACLE 按表字段值的不同统计数量的主要内容,如果未能解决你的问题,请参考以下文章

Laravel统计Mysql 单个字段不同值的数量

SQL语句:统计指定字段,等于不同值的条数

mysql 怎么统计同一字段不重复值的数量

SQL语句:统计指定字段,等于不同值的条数

sql语句统计数量,统计一个字段的值的数量

Oracle Apex - 根据值的数量显示项目