AnalystPath

Days the Reservoir Rose

SQLEasyJunior level~15 min

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.

reservoir_log
reading_idreading_daylevel_cm
12022-04-01120
22022-04-02135
32022-04-03130

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

Related SQL questions