日期:2014-05-17 浏览次数:20697 次
SELECT
country,
SUM(severity) AS s0,
COUNT(CASE WHEN severity > 40 THEN 1 END) AS s1,
COUNT(CASE WHEN severity > 80 THEN 1 END) AS s2
GROUP BY country
select country,sum(severity) as s0,
SUM(CASE WHEN severity>40 THEN 1 ELSE 0 END) as s1,
SUM(CASE WHEN severity>80 THEN 1 ELSE 0 END) as s2
from table
group by country
select country,SUM(case when severity>80 then 1 else 0 end) as s2,
SUM(case when severity>40 and severity<=80 then 1 else 0 end) as s1,
sum(severity) as s0
from tb
group by country