Days the Reservoir Rose
Problem
A water authority records the reservoir level once per day.
Table: `reservoir_log`
| Column | Type |
|---------------|------|
| reading_id | int |
| reading_day | date |
| level_cm | int |
`reading_id` has unique values and there is at most one reading per day.
Write a query that returns the `reading_id` of every day whose `level_cm` is **strictly higher** than the level on the **immediately preceding calendar day** (yesterday). Return the column `reading_id`, in any order.
Tables
Example rows — the live problem includes the full dataset.
| reading_id | reading_day | level_cm |
|---|---|---|
| 1 | 2022-04-01 | 120 |
| 2 | 2022-04-02 | 135 |
| 3 | 2022-04-03 | 130 |
Expected output
Your answer should return 2 rows with the columns reading_id.
Starter code (SQL)
SELECT *
FROM reservoir_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