Skip rate by genre
The task
The content team wants to know which genres get skipped. A play is a skip when seconds_played is less than 30. A play of exactly 30 seconds is not a skip.
A play belongs to the genre of its track's artist. Return one row for every genre found in artists:
genreskip_rate_pct, skipped plays as a percentage (0 to 100) of all plays in that genre, rounded to 1 decimal place
A genre with no plays at all has no rate, so return NULL. Sort by skip_rate_pct descending with NULL last, then genre ascending.
Expected output
genreskip_rate_pct- Sorted by skip_rate_pct descending, then genre ascending.
- Numbers rounded to 1 decimal place.
- Checked on the sample and on 2 hidden datasets. How grading works
Tables Music streaming service · click a name to insert it
listeners180 rows in the sample
One row per listener account. Key: listener_id.
| int | Unique id. | |
| date | Day they joined. | |
| text | Two-letter country code. | |
| text | free, premium or family. |
artists30 rows in the sample
One row per artist. Key: artist_id.
| int | Unique id. | |
| text | Name. | |
| text | pop, rock, hip-hop, electronic, jazz or folk. |
tracks116 rows in the sample
One row per track. Key: track_id.
| int | Unique id. | |
| text | Track title. | |
| int | Main artist. | |
| int | Length. | |
| date | Release day. |
plays6,555 rows in the sample
One row per play. Key: play_id.
| bigint | Unique id. | |
| int | Who listened. | |
| int | What. | |
| timestamp | Start time (UTC). | |
| int | How long they listened. | |
| text | phone, desktop, speaker or car. |
Related questions
Loading the editor and PostgreSQL
Loading the editor and PostgreSQL