Skip to content

Commit 54ea6a0

Browse files
authored
Create weather-type-in-each-country.sql
1 parent 7b6b9a6 commit 54ea6a0

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Time: O(m + n)
2+
# Space: O(n)
3+
4+
SELECT c.country_name,
5+
CASE
6+
WHEN AVG(w.weather_state * 1.0) <= 15.0 THEN 'Cold'
7+
WHEN AVG(w.weather_state * 1.0) >= 25.0 THEN 'Hot'
8+
ELSE 'Warm'
9+
END AS weather_type
10+
FROM Countries AS c
11+
INNER JOIN Weather AS w ON c.country_id = w.country_id
12+
WHERE w.day BETWEEN '2019-11-01' AND '2019-11-30'
13+
GROUP BY c.country_id;

0 commit comments

Comments
 (0)