Oracle -- 多个count统计一张表中多个字段等于某值

Posted wuyueping

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Oracle -- 多个count统计一张表中多个字段等于某值相关的知识,希望对你有一定的参考价值。

摘录:https://www.linuxidc.com/Linux/2012-06/62894.htm

case when 条件 then 条件为真时的值 else 条件为假时的值 end

--单独查询统一某个字段等于某值的次数
select count(m.underwriteflag) from prpcmain m where m.underwriteflag=\'1\'  ; --720407
select count(m.nationflag) from prpcmain m where m.nationflag=\'1\'         --720422

--合并查询 select count(case when m.underwriteflag=\'1\' then 1 end)字段1,count(case when m.nationflag=\'1\' then 1 end)字段2 from prpcmain m;

  

 

以上是关于Oracle -- 多个count统计一张表中多个字段等于某值的主要内容,如果未能解决你的问题,请参考以下文章

oracle数据库一张表中求两列之差并求和

Oracle查询一张表插入另一张表中

关于oracle索引数量

Oracle如何将多次分组求和的数据合并到一张表上?

SQL SERVER,一张表中,有多个字段关联另一张表,怎么写SQL语句?

如何用标准SQL语句给一张表中添加多个字段