我有一个2列的分区表 (country,status) 现在我要数一数 SUCCESS 以及 ERROR 时间 status 列。我该如何解决这个问题?
(country,status)
SUCCESS
ERROR
status
5t7ly7z51#
带有聚合的用例语句:
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 列,如果您需要总计数。
group by country
country
gv8xihay2#
您可以使用where条件来获得结果从..中选择计数(状态)。。其中status='成功';联合选择计数(状态)自。。其中status='错误';
2条答案
按热度按时间5t7ly7z51#
带有聚合的用例语句:
删除
group by country
以及country
列,如果您需要总计数。gv8xihay2#
您可以使用where条件来获得结果
从..中选择计数(状态)。。其中status='成功';联合选择计数(状态)自。。其中status='错误';