Sustained Busy Days at the Toll Plaza
Problem
A toll plaza records the number of vehicles that passed each day.
```
TollDay
+-----------+------+
| Column | Type |
+-----------+------+
| day_no | int |
| traffic_date | date |
| vehicles | int |
+-----------+------+
day_no is the primary key; rows are numbered consecutively with no gaps.
```
Find the records of every day that is part of a run of **3 or more consecutive days** (consecutive by `day_no`) where each of those days had `vehicles` of **80 or more**.
Return the qualifying rows ordered by `traffic_date`.
Tables
Example rows — the live problem includes the full dataset.
| day_no | traffic_date | vehicles |
|---|---|---|
| 1 | 2024-02-01 | 12 |
| 2 | 2024-02-02 | 95 |
| 3 | 2024-02-03 | 140 |
Expected output
Your answer should return 4 rows with the columns day_no, traffic_date, vehicles.
Starter code (SQL)
SELECT *
FROM TollDay;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