Listening Mix by Membership Tier
Problem
A media app logs how long each member spends in two modes. Table `Plays` has one row per session: `play_id`, `member_id`, `mode` (either `audio` or `video`), and `minutes` spent (decimal). Table `Members` maps each `member_id` to a membership `tier` (such as `Basic` or `Premium`).
For each membership tier, compute what percentage of the tier's total minutes was spent in `audio` mode and what percentage in `video` mode. Round both percentages to two decimal places.
Return `tier`, `audio_pct`, and `video_pct`. Order is not important.
Tables
Example rows — the live problem includes the full dataset.
| play_id | member_id | mode | minutes |
|---|---|---|---|
| 7274 | 123 | video | 4.5 |
| 2425 | 123 | audio | 3.5 |
| 1413 | 456 | audio | 5.67 |
| member_id | tier |
|---|---|
| 123 | Gold |
| 789 | Silver |
| 456 | Bronze |
Expected output
Your answer should return 3 rows with the columns tier, audio_pct, video_pct.
Starter code (SQL)
SELECT *
FROM Plays;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