Uber's loyalty team triggers a reward on a rider's third completed trip. Only trips with status = 'completed' count toward the sequence; cancelled trips are skipped. Trips are ordered by requested_at, and when two trips have the same requested_at, the lower trip_id comes first. Note that trip_id does not always follow time order. Riders with fewer than three completed trips are left out. Write an SQL query that returns rider_id, trip_id and fare for each rider's third completed trip. Order the results by rider_id 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.