SQLQuokka
Start practicing
QuestionsLearnSandboxFeaturesRoadmapFAQ

High-Volume Cities by Completed Trips

Unsolved

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.

SQL Query Editor (Ctrl+Enter to run)
0 characters · Valid
Canonical Solution Official

Official Solution is Hidden

Try solving the question with the schema explorer and hints first. When ready, reveal the verified canonical query and step-by-step logic breakdown.

Community Q&A & Discussion

Ask questions, share alternate queries, and explore solutions

0 comments
Asked By:
🏢 Uber🏢 Lyft

Submission History

Your recent query executions and answer checks

Execution Pipeline:
FROM trips
Full source dataset
15 rows total
Ready. Type a query to see live execution.
Clause: Auto-Sync · AlaSQL Engine