Skip to content

Listeners who played both jazz and folk

MediumFull bankJoinsCTEs and subqueries12 min2 hidden datasets

The task

Editorial wants to build a crossover playlist and asks how many listeners already enjoy both worlds, by country.

A listener enjoyed a genre when they have at least one play of 30 seconds or more (seconds_played >= 30) of a track by an artist of that genre.

Count the listeners who enjoyed both 'jazz' and 'folk'. Return country (the listener's country) and listeners, only for countries with at least one such listener. Sort by listeners descending, then country ascending.

Expected output

countrylisteners
  • Sorted by listeners descending, then country ascending.
  • 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