我有一个包含2列(country,status)
的分区表,现在我想计算SUCCESS
列中ERROR
和status
的次数。
我该如何解决这个问题?
答案 0 :(得分:0)
具有聚合的用例语句:
select country,
sum(case when status='SUCCESS' then 1 end) cnt_SUCCESS,
sum(case when status='ERROR' then 1 end) cnt_ERROR
from tablename
group by country;
如果需要总数,请删除group by country
和country
列。
答案 1 :(得分:0)
您可以使用where条件获取结果
从..中选择count(status),其中status ='SUCCESS'; 联盟 从..中选择count(status),其中status ='ERROR';