Skip to content

Skip rate by genre

MediumFull bankRatios and percentagesJoinsNULL handling12 min2 hidden datasets

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:

  • genre
  • skip_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.

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