题目链接:点击打开链接
题目大意:略。
解题思路:注意解决方案(1) LEFT 玩法。
AC 代码
--解决方案(1) SELECTCOUNTRY_NAME, CASEWHENAVG(WEATHER_STATE) <=15THEN'Cold'WHENAVG(WEATHER_STATE) >=25THEN'Hot'ELSE'Warm'ENDASWEATHER_TYPEFROMCOUNTRIESASCINNERJOINWEATHERASWONC.COUNTRY_ID=W.COUNTRY_IDWHERELEFT(DAY, 7) ='2019-11'GROUPBY1; --解决方案(2) SELECTcountry_name, IF(AVG(weather_state) <=15, 'Cold', IF(AVG(weather_state) >=25, 'Hot', 'Warm')) weather_typeFROMWeatherwJOINCountriescONc.country_id=w.country_idWHEREDATE_FORMAT(day, '%Y-%m') ='2019-11'GROUPBYw.country_id