Skip to content

Full-play rate by genre

EasyFull bankConditional aggregationJoinsRatios and percentages10 min2 hidden datasets

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:

  • genre
  • plays: number of plays
  • full_plays: number of full plays
  • full_play_pct: full_plays as a percentage of plays, 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.

intUnique id.
dateDay they joined.
textTwo-letter country code.
textfree, premium or family.
artists30 rows in the sample

One row per artist. Key: artist_id.

intUnique id.
textName.
textpop, rock, hip-hop, electronic, jazz or folk.
tracks116 rows in the sample

One row per track. Key: track_id.

intUnique id.
textTrack title.
intMain artist.
intLength.
dateRelease day.
plays6,555 rows in the sample

One row per play. Key: play_id.

bigintUnique id.
intWho listened.
intWhat.
timestampStart time (UTC).
intHow long they listened.
textphone, desktop, speaker or car.

Related questions

Loading the editor and PostgreSQL