The Plan Mix
Pricing at StreamVerse is about to move the middle tier, and the first thing they need is the shape of the customer base: how the subscribers split across the basic, standard and premium plans. A plan with two people on it is a very different conversation from one with two hundred.
subscribers — one row per person who pays for StreamVerse. plan is one of basic, standard or premium; country is a two-letter market code; signup_date is the day they signed up.
| 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 that returns one row per plan, with columns plan and n, n being how many subscribers are on that plan. Put the busiest plan first; two plans holding the same number of subscribers come back in alphabetical order of plan.
Example output
Shape only — the plan names are the real ones, the figures are invented:
| plan | n |
|---|---|
| standard | 140 |
| basic | 96 |
| premium | 96 |
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