AnalystPath

Sustained Busy Days at the Toll Plaza

SQLHardSenior level~15 min

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.

TollDay
day_notraffic_datevehicles
12024-02-0112
22024-02-0295
32024-02-03140

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

Related SQL questions