当前位置:Gxlcms > 数据库问题 > ORACLE 按表字段值的不同统计数量

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

时间:2021-07-01 10:21:17 帮助过:132人阅读

  1. select p.id comperitorId,p.compcorp competitorName,
  2. sum(case when c.kindname = ‘ATM‘ then c.num else 0 end) atm,
  3. sum(case when c.kindname = ‘CRS‘ then c.num else 0 end) crs,
  4. sum(case when c.kindname = ‘VTM‘ then c.num else 0 end) vtm,
  5. sum(case when c.kindname = ‘清分机‘ then c.num else 0 end) sorter,
  6. sum(case when c.kindname = ‘软件‘ then c.num else 0 end) software,
  7. sum(case when c.kindname = ‘其他‘ then c.num else 0 end) other,
  8. m.iscommunication iscommunication
  9. from compproduct c
  10. join competitor p on c.competitor_id=p.id
  11. 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
  12. where c.cust_id=‘7649‘
  13. group by p.id,c.competitor_id,p.compcorp,m.iscommunication

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

标签:ati   end   pos   atm   ase   ora   comm   tracking   track   

人气教程排行