Subscriber Count per Channel
Problem
Table: `subscription`
| Column Name | Type |
|---|---|
| channel_id | int |
| subscriber_id | int |
`(channel_id, subscriber_id)` is the primary key. Each row means `subscriber_id` is subscribed to the podcast `channel_id`.
For each channel, return the number of subscribers it has. Alias the count `subscriber_count` and return the result ordered by `channel_id` ascending.
Tables
Example rows — the live problem includes the full dataset.
subscription
| channel_id | subscriber_id |
|---|---|
| 1 | 10 |
| 1 | 11 |
| 1 | 12 |
Expected output
Your answer should return 2 rows with the columns channel_id, subscriber_count.
Starter code (SQL)
SELECT *
FROM subscription;Solve this SQL question free
Write SQL and run it instantly in your browser — even on your phone. No signup needed to try.
Solution & explanation
Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.
Sign up free to unlock