Sign in to run and submit your work
Reading is open to everyone. Running code and saving drafts need an account so your work is yours and comes back on your next visit.
or
CODE WORKSPACE
Operations promises a driver within 60 seconds of a ride request. rapido_allocation_events records assignment attempts, and the dispatcher retries, so one request can have several. A request that never found a driver has no assignment event at all.
Return one row per city, ordered by breach rate descending.
Result columns · in this order
city | The city. |
requests | All ride requests there. |
within_sla | Assigned a driver within 60 seconds. |
breached | Assigned late, or never assigned. |
breach_rate_pct | Breaches as a percentage of requests. |
How to approach it
Compare the request ids in the two tables first. The difference between them is the answer's hardest part.
Sample input
| request_id | city | rider_id | requested_at |
|---|---|---|---|
| 301 | Bengaluru | rd1 | 2026-03-02 08:00:00 |
| 302 | Bengaluru | rd2 | 2026-03-02 08:05:00 |
| 303 | Bengaluru | rd3 | 2026-03-02 08:10:00 |
| 304 | Bengaluru | rd4 | 2026-03-02 08:20:00 |
| 305 | Hyderabad | rd5 | 2026-03-02 09:00:00 |
| 306 | Hyderabad | rd6 | 2026-03-02 09:04:00 |
| 307 | Hyderabad | rd7 | 2026-03-02 09:09:00 |
| 308 | Pune | rd8 | 2026-03-02 10:00:00 |
| 309 | Pune | rd9 | 2026-03-02 10:03:00 |
| 310 | Pune | rd10 | 2026-03-02 10:06:00 |
| 311 | Pune | rd11 | 2026-03-02 10:12:00 |
| 312 | Bengaluru | rd12 | 2026-03-02 08:30:00 |
12 rows — scroll inside the table to see them all.
| event_id | request_id | event_type | event_at |
|---|---|---|---|
| 1 | 301 | driver_assigned | 2026-03-02 08:00:25 |
| 2 | 301 | driver_assigned | 2026-03-02 08:01:40 |
| 3 | 302 | driver_assigned | 2026-03-02 08:07:10 |
| 4 | 303 | cancelled | 2026-03-02 08:11:00 |
| 5 | 304 | driver_assigned | 2026-03-02 08:20:45 |
| 6 | 305 | driver_assigned | 2026-03-02 09:00:30 |
| 7 | 306 | driver_assigned | 2026-03-02 09:06:20 |
| 8 | 308 | driver_assigned | 2026-03-02 10:00:15 |
| 9 | 309 | driver_assigned | 2026-03-02 10:03:55 |
| 10 | 310 | driver_assigned | 2026-03-02 10:08:30 |
| 11 | 311 | cancelled | 2026-03-02 10:13:30 |
| 12 | 312 | driver_assigned | 2026-03-02 08:30:20 |
| 13 | 305 | driver_assigned | 2026-03-02 09:02:00 |
13 rows — scroll inside the table to see them all.
Expected output
| city | requests | within_sla | breached | breach_rate_pct |
|---|---|---|---|---|
| Hyderabad | 3 | 1 | 2 | 66.7 |
| Pune | 4 | 2 | 2 | 50 |
| Bengaluru | 5 | 3 | 2 | 40 |
3 rows — all rows shown.
Constraints
requests counts every row in rapido_requests for that city — 5 for Bengaluru, 3 for Hyderabad, 4 for Pune.requested_at.within_sla plus breached must equal requests for every city.breach_rate_pct descending, then city.Worked example
Hyderabad has 3 requests. 305 was assigned in 30 seconds, 306 took 140 seconds, and 307 never found a driver — no row in the events table. The honest answer is 1 within SLA, 2 breached, a 66.7% breach rate. Join the two tables and count what you find, and 307 disappears: Hyderabad reports 2 requests with a 50% breach rate. The worst outcome in the dataset — a rider who was never served — is the one the join cannot see, so the metric flatters exactly where it should not.
What this tests
That the rows which are absent carry the signal. Any SLA, funnel or coverage metric has to be driven from the table that contains every attempt, with the outcome joined onto it, or the failures quietly leave the denominator.
Submit for review to find out what your query gets right, what it gets wrong, and how it compares with the best working query for this exercise.
This scenario runs a full workspace — editor, canvas and results side by side. It needs a laptop or desktop to be usable. Open this page on a bigger screen to start building.