题目来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/weather-type-in-each-country
著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。
本人思路:
1、题目不难,但是要注意判断语句的写法
select c.country_name ,temp.weather_type
from Countries as c inner join(
select
country_id ,
case
when avg(weather_state)<=15 then 'Cold'
when avg(weather_state)>=25 then 'Hot'
else 'Warm'
end as weather_type
from Weather
where date_format(day,'%Y-%m')='2019-11'
group by country_id
)temp
on c.country_id = temp.country_id