How Many Cities Is UrbanHop In?
UrbanHop's expansion team is finishing a board deck and one line on the opening slide says how many cities the service currently operates in. Somebody needs to confirm that number against the actual rider list before it goes out.
The rider table records the city each rider is in, one city per rider. It is a list of people, not a list of cities, so the same city appears on several rows — and a city with four riders is still one city on the slide.
riders — one row per registered rider. city is the city that rider is based in.
| 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 returning a single row with a single column, num_cities, holding the number of different cities the riders are spread across. Each city counts once no matter how many riders live there.
Example output — shape only. If the riders were spread across eight cities, the single row would read:
| num_cities |
|---|
| 8 |
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