Pool all days together and group requests by city and hour of day (0-23, from requested_at). The peak hour of a city is the hour with the most requests; ties go to the hour with the higher share of status 'NO_DRIVER', and if still tied, to the earlier hour. Return city, peak_hour (integer), requests and no_driver_pct = 100 * NO_DRIVER requests / requests in that hour, ROUND to 1. Order by city.
| Column | Type |
|---|---|
| request_id | INTEGER |
| city | TEXT |
| requested_at | TIMESTAMP |
| status | TEXT |
| request_id | city | requested_at | status |
|---|---|---|---|
| 1 | Bengaluru | 2026-06-01 09:05:00 | COMPLETED |
| 2 | Bengaluru | 2026-06-01 09:40:00 | NO_DRIVER |
| 3 | Bengaluru | 2026-06-02 09:15:00 | COMPLETED |
| 4 | Bengaluru | 2026-06-01 18:10:00 | CANCELLED |
| 5 | Bengaluru | 2026-06-02 18:20:00 | COMPLETED |
| 6 | Pune | 2026-06-01 08:00:00 | COMPLETED |
| 7 | Pune | 2026-06-01 20:30:00 | NO_DRIVER |
| 8 | Pune | 2026-06-02 20:45:00 | COMPLETED |
| city | peak_hour | requests | no_driver_pct |
|---|---|---|---|
| Bengaluru | 9 | 3 | 33.3 |
| Pune | 20 | 2 | 50 |
Solve it in the live editor on this page — run on sample data, then submit against hidden tests.
‹ Quarterly Quota Attainment Ranking · Sessionize App Events and Cart Conversion ›
{{ 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.