Stations With a Warming Streak
Problem
Table: `reading_log`
| Column Name | Type |
|---|---|
| reading_id | int |
| station_id | int |
| read_on | date |
| high_celsius | int |
`reading_id` is the primary key. Each row is one station's recorded daily high temperature. A station records at most one reading per day.
Find every station that had a *warming streak*: at least three consecutive calendar days where each day's `high_celsius` was strictly greater than the day before. For each such station, report `station_id`, the streak's first date as `streak_start`, and the streak's last date as `streak_end`. Order by `station_id`.
Tables
Example rows — the live problem includes the full dataset.
| reading_id | station_id | read_on | high_celsius |
|---|---|---|---|
| 1 | 101 | 2023-06-01 | 20 |
| 2 | 101 | 2023-06-02 | 23 |
| 3 | 101 | 2023-06-03 | 27 |
Expected output
Your answer should return 1 row with the columns station_id, streak_start, streak_end.
Starter code (SQL)
SELECT *
FROM reading_log;Solve this SQL question free
Write SQL and run it instantly in your browser — even on your phone. No signup needed to try.
Solution & explanation
Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.
Sign up free to unlock