…
…
From a month of readings for five cities, find the coldest days, the missing measurements, the city summaries and the rainy days.
For a weather website you will prepare a monthly report from the November 2026 readings of five cities (Port Alder, Lisbon, Toronto, Nairobi, Seoul). Every city has one row per day: the lowest and highest temperature, the amount of rain and the wind speed. On some days the rain sensor could not measure, so those cells are empty. The report has to handle these gaps correctly: a day without a measurement is not a "dry day".
Data: one table, reading (id, city, reading_date, temp_min, temp_max, rain_mm, wind_kmh). Temperatures are in °C. The values are fictional sample data.
Lessons used: WHERE and sorting (4–6), NULL (7), CASE (8), aggregation, GROUP BY and HAVING (11–13).
What you'll do
weather.sqlDownload file
Reading file…
Code cells are for members
You can read the steps. Sign up free to run the code, complete the steps and save your progress.
Toronto often dips below freezing in November. The report will highlight the days when the lowest temperature fell below -10 degrees.
Show the reading_date and temp_min of the days in Toronto where temp_min is below -10 (temp_min < -10). The coldest day comes first; on ties, sort by date.
This step's code cell is for members.Sign up free
Days with a large temperature swing show up in inland areas and under clear skies. You will calculate the difference and find the five biggest swings.
For every row show city, reading_date and the daily difference (swing = temp_max − temp_min). List the 5 days with the largest swing; on ties, sort by city, then date.
This step's code cell is for members.
Code cells are for members
You can read the steps. Sign up free to run the code, complete the steps and save your progress.
Before publishing the report you need to know how complete the data is. COUNT(*) counts every row, while COUNT(column) counts only the non-NULL values of that column; the difference is the number of missing measurements.
For every city show the number of days (days), the number of days with a rain measurement (measured) and the number of missing measurements (missing). Sort by city.
This step's code cell is for members.Sign up free
The main table of the report is each city's monthly summary. Aggregate functions ignore NULL values, so total rainfall is only the sum of the days that were measured.
For every city show the average high temperature (avg_high, one decimal), the lowest temperature of the month (coldest) and the total rainfall (total_rain). The city with the highest average high comes first.
This step's code cell is for members.Sign up free
You will sort every day into one of three types: 1 mm or more of rain is rainy, less is dry, and no measurement is no reading. Watch out: the condition rain_mm >= 1 is neither true nor false for NULL; it gives unknown. If you do not put the NULL check first, the days that could not be measured fall into ELSE and are counted as "dry".
Show the number of days (days) by city and day type. Sort by city, then day type.
This step's code cell is for members.Sign up free
To show that the weather cools through November, you will split the month in two. Dates are written in single quotes in year-month-day order and compared in calendar order.
Label days 1–15 as Nov 1-15 and days 16–30 as Nov 16-30 (period). For every city and period show the average high temperature (avg_high, one decimal). Sort by city, then period.
This step's code cell is for members.Sign up free
The last box of the report: cities with at least 9 rainy days in November. To count rainy days you can use CASE to produce 1 or 0 and add them up. Filtering after grouping is done with HAVING.
Show the name of every city with at least 9 rainy days (rain ≥ 1 mm) and the number of rainy days (rainy_days). The city with the most rainy days comes first; on ties, sort by city name.
This step's code cell is for members.Sign up free