diff --git a/solution/1200-1299/1294.Weather Type in Each Country/README.md b/solution/1200-1299/1294.Weather Type in Each Country/README.md index 2e97ddf3535b7..d5adb7ffa8866 100644 --- a/solution/1200-1299/1294.Weather Type in Each Country/README.md +++ b/solution/1200-1299/1294.Weather Type in Each Country/README.md @@ -122,15 +122,15 @@ Morocco 11 月的平均 weather_state 为 (25 + 27 + 31) / 3 = 27.667 所以天 SELECT country_name, CASE - WHEN avg(weather_state) <= 15 THEN 'Cold' - WHEN avg(weather_state) >= 25 THEN 'Hot' + WHEN AVG(weather_state) <= 15 THEN 'Cold' + WHEN AVG(weather_state) >= 25 THEN 'Hot' ELSE 'Warm' END AS weather_type FROM Weather AS w - JOIN Countries AS c ON w.country_id = c.country_id -WHERE date_format(day, '%Y-%m') = '2019-11' -GROUP BY w.country_id; + JOIN Countries USING (country_id) +WHERE DATE_FORMAT(day, '%Y-%m') = '2019-11' +GROUP BY 1; ``` diff --git a/solution/1200-1299/1294.Weather Type in Each Country/README_EN.md b/solution/1200-1299/1294.Weather Type in Each Country/README_EN.md index 9772c6a96e9f3..33516304071a9 100644 --- a/solution/1200-1299/1294.Weather Type in Each Country/README_EN.md +++ b/solution/1200-1299/1294.Weather Type in Each Country/README_EN.md @@ -117,15 +117,15 @@ We know nothing about the average weather_state in Spain in November so we do no SELECT country_name, CASE - WHEN avg(weather_state) <= 15 THEN 'Cold' - WHEN avg(weather_state) >= 25 THEN 'Hot' + WHEN AVG(weather_state) <= 15 THEN 'Cold' + WHEN AVG(weather_state) >= 25 THEN 'Hot' ELSE 'Warm' END AS weather_type FROM Weather AS w - JOIN Countries AS c ON w.country_id = c.country_id -WHERE date_format(day, '%Y-%m') = '2019-11' -GROUP BY w.country_id; + JOIN Countries USING (country_id) +WHERE DATE_FORMAT(day, '%Y-%m') = '2019-11' +GROUP BY 1; ``` diff --git a/solution/1200-1299/1294.Weather Type in Each Country/Solution.sql b/solution/1200-1299/1294.Weather Type in Each Country/Solution.sql index c1179cf569b54..a0944ddc293a9 100644 --- a/solution/1200-1299/1294.Weather Type in Each Country/Solution.sql +++ b/solution/1200-1299/1294.Weather Type in Each Country/Solution.sql @@ -1,13 +1,12 @@ -# Write your MySQL query statement below SELECT country_name, CASE - WHEN avg(weather_state) <= 15 THEN 'Cold' - WHEN avg(weather_state) >= 25 THEN 'Hot' + WHEN AVG(weather_state) <= 15 THEN 'Cold' + WHEN AVG(weather_state) >= 25 THEN 'Hot' ELSE 'Warm' END AS weather_type FROM Weather AS w - JOIN Countries AS c ON w.country_id = c.country_id -WHERE date_format(day, '%Y-%m') = '2019-11' -GROUP BY w.country_id; + JOIN Countries USING (country_id) +WHERE DATE_FORMAT(day, '%Y-%m') = '2019-11' +GROUP BY 1;