IntermediateSet Operators25 points

The comeback kids of 2026

The retention team wants a win-back story. A comeback listener is someone who (a) played something in the first half of 2025 (before 2025-07-01), (b) played something again in 2026 (on or after 2026-01-01), but (c) played nothing at all in the second half of 2025 (2025-07-01 to 2025-12-31).

Task: return user_id and name of every comeback listener, sorted by user_id. Hint for the approach: three sets of user ids combined with INTERSECT and EXCEPT make this short.

The data you can query

Each table is shown with its column types and the first rows, so you can see exactly what the data looks like.

artists16 rows
artist_id INTEGERartist_name TEXThome_country TEXTgenre TEXT
1Tobi AdeyemiNigeriaAfrobeats
2Nala OseiGhanaAfrobeats
3Neon HanbokSouth KoreaK-Pop
4Pixel OrchidSouth KoreaK-Pop
5Luz de AlbaMexicoLatin Pop
6Rio CalienteBrazilLatin Pop

Showing the first 6 of 16 rows.

plans4 rows
plan_id INTEGERplan_name TEXTmonthly_price REAL
1Free0
2Student4.99
3Premium9.99
4Family14.99
plays365 rows
play_id INTEGERuser_id INTEGERtrack_id INTEGERplayed_at TEXTseconds_played INTEGERdevice TEXT
12152025-02-10 09:10:00174mobile
21172025-03-12 11:10:00253smart_speaker
313332025-03-25 14:26:23140desktop
413132025-03-25 14:51:34245smart_speaker
512132025-04-01 12:10:00272desktop
610132025-04-11 10:10:00272smart_tv

Showing the first 6 of 365 rows.

subscriptions51 rows
sub_id INTEGERuser_id INTEGERplan_id INTEGERstart_date TEXTend_date TEXTstatus TEXT
1132025-01-072025-09-03cancelled
2132025-11-302026-01-02cancelled
3332025-01-202025-08-23cancelled
4522025-01-28NULLactive
5642025-02-022025-03-27cancelled
6732025-02-062025-10-04cancelled

Showing the first 6 of 51 rows.

tracks48 rows
track_id INTEGERtitle TEXTartist_id INTEGERrelease_year INTEGERduration_sec INTEGER
1Midnight Lagos12019353
2Golden Highway12024156
3Paper Lanterns12022253
4Neon Rain22025249
5Velvet Satellite22026176
6Broken Harbor22020157

Showing the first 6 of 48 rows.

users60 rows
user_id INTEGERname TEXTcountry TEXTsignup_date TEXTplan_id INTEGERbirth_year INTEGER
1Aarav IyerIndia2025-01-0711998
2Diego SalazarMexico2025-01-1211982
3Lucas AlmeidaBrazil2025-01-1711976
4Oliver HartleyUnited Kingdom2025-01-2211978
5Priya BanerjeeUnited Kingdom2025-01-2721999
6Jordan WhitakerUnited States2025-02-0112006

Showing the first 6 of 60 rows.

Your query runs on SQLite. Write a single SELECT; use LIMIT instead of TOP.

Need a hint?

Build one query per time window that selects user_id, then combine them left to right.