Full-play rate by genre
The task
Editorial wants to know which genres hold a listener to the end of the track.
A play is a full play when seconds_played is at least the track's duration_seconds. Each play belongs to the genre of its track's artist.
Return one row for every genre that appears in artists, including genres whose artists have no plays, with:
genreplays: number of playsfull_plays: number of full playsfull_play_pct:full_playsas a percentage ofplays, rounded to 1 decimal place, or NULL when the genre has no plays
Sort by genre ascending.
Expected output
genreplaysfull_playsfull_play_pct- Sorted by 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