AnalystPath

Monthly Stream Activity Above the Royalty Floor

SQLEasyJunior level~15 min

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.

StreamPlays
play_idplayed_onlistener_idroyalty_cents
12022-03-0450145
22022-03-1950260
32022-04-0250330

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

Related SQL questions