Uber's city operations team wants a quick revenue snapshot of its busiest markets. A city qualifies if it has at least 3 trips with `trip_status = 'completed'`. Cancelled trips must not count toward the threshold or the revenue figures. Write an SQL query that returns, for each qualifying city: `city`, `completed_trips` (number of completed trips), `total_fare` (sum of `fare_amount` for completed trips) and `avg_fare` (average completed fare rounded to 2 decimal places). Order the results by `total_fare` descending, then `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.