oracle 统计多个满足条件字段数量

来源:互联网 发布:淘宝网波西米亚长裙 编辑:程序博客网 时间:2024/04/28 16:13

转载

Oracle统计多个,满足条件的字段的数

 

Table:ABCTable

a    b     c

1    2     1

2    1     3

3    1     2

  www.2cto.com  

统计a=1的有几个,b=1的有几个,c=1的有几个

 

1. select  count(*)  from ABCTable where a=1;

    select  count(*)  from ABCTable where b=1;

    select  count(*)  from ABCTable where c=1;

 

2. SELECT  SUM(CASE WHEN a=1 THEN 1 ELSE 0 END) ,

                         SUM(CASE WHEN b=1 THEN 1 ELSE 0 END) ,

                   SUM(CASE WHEN c=1 THEN 1 ELSE 0 END) ,

     FROM  ABCTable t ; 

此文章转载于https://www.2cto.com/database/201303/192461.html


阅读全文
0 0
原创粉丝点击