Monthly Stream Activity Above the Royalty Floor
Problem
A music-streaming service logs every paid play in the `StreamPlays` table. For each calendar month, report how many plays earned **more than 25 cents** in royalties and how many distinct listeners those plays came from.
Columns:
- `play_id` (int) — unique id of the play
- `played_on` (date) — date the track was streamed
- `listener_id` (int) — id of the listener
- `royalty_cents` (int) — royalty earned by the play, in cents
Return one row per month (formatted `YYYY-MM`) with the number of qualifying plays and the number of distinct qualifying listeners. Only months that have at least one qualifying play appear. Rows may be in any order.
Tables
Example rows — the live problem includes the full dataset.
| play_id | played_on | listener_id | royalty_cents |
|---|---|---|---|
| 1 | 2022-03-04 | 501 | 45 |
| 2 | 2022-03-19 | 502 | 60 |
| 3 | 2022-04-02 | 503 | 30 |
Expected output
Your answer should return 4 rows with the columns play_month, play_count, listener_count.
Starter code (SQL)
SELECT *
FROM StreamPlays;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