Uber's marketplace team wants to know where riders wait longest for a driver. trip_events logs a 'requested' event for every trip and an 'accepted' event when a driver accepts; trips that were never accepted have no 'accepted' event and are ignored. A trip is slow when more than 90 seconds pass between its requested and accepted events (exactly 90 seconds is not slow). Bucket slow trips by city and the hour of the request (0 to 23). Write an SQL query that returns the bucket or buckets with the most slow trips as city, request_hour and slow_trips. If several buckets tie for the most, return all of them. Order the results by city ascending.
Loading…
Try solving the question with the schema explorer and hints first. When ready, reveal the verified canonical query and step-by-step logic breakdown.
Ask questions, share alternate queries, and explore solutions
Your recent query executions and answer checks
This will insert the verified MySQL solution into your editor so you can study how each clause transforms the table.