我有第一张桌子,显示白天城市的降雨量。作为请求,我必须显示下雨的天数,如第二个表格。
关于如何做到这一点的任何想法?
答案 0 :(得分:1)
SELECT City,
sum(case when rain = 0 then 1 else 0 end) as '0',
sum(case when (rain> 0 and rain<= 1) then 1 else 0 end) as ']0-1]',
sum(case when (rain> 1 and rain<= 2) then 1 else 0 end) as ']1-2]',
sum(case when (rain> 2) then 1 else 0 end) as '>2'
FROM MeteoData
group by City;