A driver is *active* on a calendar day if they completed at least one trip that day (several trips on one day still count as one day). For each driver find their longest run of consecutive active days. Return `driver_id`, `longest_streak_days`, `streak_start` (first date of that run, 'YYYY-MM-DD'; if two runs tie, use the earliest one). Order by `driver_id`.
| Column | Type |
|---|---|
| trip_id | INTEGER |
| driver_id | INTEGER |
| trip_ts | TIMESTAMP |
| trip_id | driver_id | trip_ts |
|---|---|---|
| 1 | 1 | 2026-03-01 08:10:00 |
| 2 | 1 | 2026-03-01 18:40:00 |
| 3 | 1 | 2026-03-02 09:00:00 |
| 4 | 1 | 2026-03-03 23:55:00 |
| 5 | 1 | 2026-03-05 07:30:00 |
| 6 | 1 | 2026-03-06 10:00:00 |
| 7 | 2 | 2026-03-01 12:00:00 |
| 8 | 2 | 2026-03-03 12:00:00 |
| driver_id | longest_streak_days | streak_start |
|---|---|---|
| 1 | 3 | 2026-03-01 |
| 2 | 2 | 2026-03-03 |
Solve it in the live editor on this page — run on sample data, then submit against hidden tests.
‹ Frequently Bought Together Pairs · Driver Idle Time Between Rides ›
{{ totalCount }} questions in the style asked at Amazon, Microsoft, Google, Meta, Flipkart and more — {{ hardPct }}% Hard. Write SQL in a real database engine in your browser, run it on sample data, then evaluate against hidden tests.
Company tags show where this type of question is commonly reported in interviews. Questions, data and solutions are written by TechTown.
{{ cur.statement }}
No submissions yet. Press Evaluate to submit your query.
{{ solutionSql }}
{{ out.error }}
You have solved your 3 free questions — nice work! Log in (free) to unlock all 150 questions, keep your streak and appear on the leaderboard.