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) ,
&nbsoracle账号p; FROM ABCTable t ;