Genre Share of Attention
The StreamVerse strategy deck does not put raw minutes on a slide, because 195 means nothing without knowing what it is 195 out of. Every genre gets its slice of total platform attention as a percentage instead, to one decimal place.
watch_events — one row per watch session: one sitting in which one subscriber watched one show. subscriber_id points at a row in subscribers, show_id at a row in shows, and watch_minutes is how long that sitting lasted. The same person can appear many times.
| id | subscriber_id | show_id | watch_minutes | watch_date |
|---|---|---|---|---|
| 1 | 1 | 1 | 45 | 2023-05-01 |
| 2 | 1 | 5 | 60 | 2023-05-03 |
| 3 | 2 | 3 | 20 | 2023-05-02 |
| 4 | 3 | 2 | 55 | 2023-05-05 |
| 5 | 4 | 1 | 40 | 2023-05-06 |
| 6 | 4 | 4 | 70 | 2023-05-08 |
| 7 | 1 | 3 | 25 | 2023-05-10 |
| 8 | 3 | 5 | 50 | 2023-05-11 |
| 9 | 2 | 2 | 30 | 2023-05-12 |
| 10 | 5 | 4 | 65 | 2023-05-14 |
shows — one row per title in the catalogue. genre is a single label such as sci-fi or drama; release_year is the year the title came out.
| id | title | genre | release_year |
|---|---|---|---|
| 1 | Nebula Drift | sci-fi | 2021 |
| 2 | The Long Kitchen | drama | 2019 |
| 3 | Byte Size | comedy | 2022 |
| 4 | Deep Trench | documentary | 2020 |
| 5 | Neon Alley | sci-fi | 2023 |
Both tables already exist in the database — there is nothing to create or load.
Task: Write a query that returns two columns, genre and share_pct, one row per genre watched at least once. share_pct is that genre's minutes expressed as a percentage of the platform's total watch minutes, rounded to 1 decimal place. Largest slice first; two genres on the same percentage come back in alphabetical order of genre.
Example output
Shape only — these genres and shares are invented. A whole percentage comes back as 24, not 24.0:
| genre | share_pct |
|---|---|
| thriller | 51.2 |
| romance | 24 |
| horror | 18.3 |
| western | 6.5 |
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