Where Do Our Premium Viewers Live?
StreamVerse's regional marketing lead is deciding which countries get the premium-tier ad budget this quarter. She wants a country-by-country count of the subscribers already on that tier, on the theory that a country with existing premium viewers is the easier place to find more.
Every subscriber row carries both a tier and a country, so both facts are on hand — the work is in combining them. Countries with no premium subscriber at all are not interesting to her, and she is happy for them to be absent from the list rather than shown as zero.
subscribers — one row per subscriber. plan is the tier they pay for, one of basic, standard or premium. country is a two-letter code.
| id | name | plan | signup_date | country |
|---|---|---|---|---|
| 1 | Ana Torres | premium | 2022-11-01 | US |
| 2 | Ben Osei | basic | 2023-01-15 | UK |
| 3 | Chloe Martin | standard | 2023-02-20 | US |
| 4 | Dev Malhotra | premium | 2023-03-10 | IN |
| 5 | Ella Novak | basic | 2023-04-05 | UK |
The table already exists in the database — there is nothing to create or load.
Task: Write a query returning two columns, country and num_subscribers, with one row for each country that has at least one premium subscriber. Countries with none produce no row. Rows come back in alphabetical order of country.
Example output — shape only; the figures below are invented, not this data's answer.
| country | num_subscribers |
|---|---|
| BR | 4 |
| SE | 2 |
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