How far each artist climbed or fell from April to May
The task
The charts team publishes a monthly artist ranking and wants to show movement. For each of April 2025 and May 2025, add up the seconds_played of every artist's tracks (a play belongs to the month of played_at) and rank all artists that had at least one play that month, most seconds first. Artists with the same total share a rank, and the next rank skips ahead (1, 1, 3).
Return the artists that were ranked in both months, with:
artist_nameapril_rankmay_rankplaces_gained:april_rankminusmay_rank, so a positive number means the artist moved up the chart.
Ranks are computed among all artists with plays that month, including ones that were only ranked in one of the two months. Sort by places_gained descending, then artist_name ascending.
Expected output
artist_nameapril_rankmay_rankplaces_gained- Sorted by places_gained descending, then artist_name ascending.
- Checked on the sample and on 3 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
- Listener quartiles by May listening timemedium
- Top two artists each month by listening timemedium
- Favourite spending category per customer, counted by segmenthard
- First order value by acquisition channelmedium
- Genre of each listener's first playmedium
- Months each merchant ranked in the top three for spendmedium
Loading the editor and PostgreSQL
Loading the editor and PostgreSQL