AnalystPath

Total Parking Minutes per Vehicle

SQLEasyJunior level~15 min

Problem

Table: `parking_event`

| Column Name | Type |
|---|---|
| vehicle_id | int |
| park_date | date |
| enter_min | int |
| exit_min | int |

`(vehicle_id, park_date, enter_min)` is the primary key. Each row records one parking stay: a vehicle entered a garage at minute `enter_min` and left at minute `exit_min` on `park_date`. A vehicle may park several times in one day.

For each `park_date` and `vehicle_id`, report the total number of minutes the vehicle spent parked that day. Output columns `park_date` aliased `day`, `vehicle_id`, and the total aliased `total_minutes`.

Tables

Example rows — the live problem includes the full dataset.

parking_event
vehicle_idpark_dateenter_minexit_min
12026-02-103090
12026-02-10100130
22026-02-10045

Expected output

Your answer should return 3 rows with the columns day, vehicle_id, total_minutes.

Starter code (SQL)

SELECT *
FROM parking_event;

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