Demand-Side Signups
Supply is only half of UrbanHop's planning problem. The other half is demand, and the first cut at it is a signup headcount per city, which the planning team reads next to the driver headcount to see which cities are lopsided — plenty of riders and nobody to carry them, or the reverse.
The cities exist only as text on each rider's row, so this report covers exactly the cities somebody has signed up in. A city UrbanHop has launched in but nobody has joined from produces no line at all.
riders — one row per registered passenger. city is the city they signed up in and signup_date the day they joined.
| id | name | city | signup_date |
|---|---|---|---|
| 1 | Maya Chen | Austin | 2023-01-05 |
| 2 | Noah Patel | Denver | 2023-02-14 |
| 3 | Zara Ahmed | Austin | 2023-03-01 |
| 4 | Leo Kim | Seattle | 2023-04-20 |
| 5 | Ivy Brooks | Denver | 2023-05-11 |
The table already exists in the database — there is nothing to create or load.
Task: Write a query that returns one row per city, with city and how many riders signed up there as n_riders. Largest first; cities with the same number of riders are separated alphabetically by city.
Example output
Shape only — these cities and headcounts are invented:
| city | n_riders |
|---|---|
| Portland | 5 |
| Boise | 3 |
| Tulsa | 3 |
Sign in to solve this problem
Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.
Sign in