AnalystPath

Stations With a Warming Streak

SQLHardSenior level~15 min

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_log
reading_idstation_idread_onhigh_celsius
11012023-06-0120
21012023-06-0223
31012023-06-0327

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

Related SQL questions