Skip to content

feat: update sql solution to lc problem: No.1294 #1811

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions solution/1200-1299/1294.Weather Type in Each Country/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
```

<!-- tabs:end -->
Original file line number Diff line number Diff line change
Expand Up @@ -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;
```

<!-- tabs:end -->
Original file line number Diff line number Diff line change
@@ -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;