Leetcode. 1294. 不同国家的天气类型(非常经典的order by +where限制分组查询)

2021-04-16 10:18:03 浏览数 (1)

代码语言:javascript复制
select c.country_name,
    case when avg(w.weather_state)<=15 then "Cold"
         when avg(w.weather_state)<25 then "Warm"
         else "Hot" end weather_type
    from countries c
    inner join 
    weather w 
    on c.country_id =w.country_id
    where left(w.day,7)="2019-11"
    group by 1

0 人点赞