SQL interview questions · By company
Spotify SQL interview questions
For data analyst and data scientist roles: what candidates report, and how to practice for it.
SQLRep isn't affiliated with or endorsed by Spotify. This guide summarizes public candidate reports and prep guides (sources below, checked November 2026). The practice questions are original, written in the reported style; they aren't Spotify's actual questions. Processes change, so confirm details with your recruiter.
What candidates report about the process
- Public question lists come mainly from prep sites that tag practice problems by company.
- Treat these topics as indicative, not confirmed.
SQL topics that come up
- Streaming history: cumulative counts across tables
- Top songs or artists per group, with ties
- Repeat listening and streaks
Practice the reported patterns
Each one runs in real PostgreSQL in your browser, with feedback on what's wrong.
- All-time streams from history plus todayCombine the two tables into each song's all-time streams and return the top 5 songs: title, artist and total_streams. Sort by total_streams descending, then title.Pattern: UNION ALL · SUM per key · LIMITMediumPro
- Same song on 3+ days in one weekReturn user_id, title, week_start (the Monday of the week, as a date), listen_days (distinct days that week with a play of that song) and plays (total plays of it that week) for every user, song and week with listen_days of 3 or more. Sort by week_start, user_id, then title.Pattern: COUNT(DISTINCT date) · date_trunc('week') · HAVINGHardPro
- Top artist per country, ties includedUsing March 2025 streams only, return country, artist and total_streams for the artist with the most total streams in each country. If artists tie for first, return all of them. Sort by country, artist.Pattern: RANK() · top-1 per group with tiesMediumPro
- Total touchpoints per userReturn user_id and touches (number of logins plus number of events) for every user who appears in either table. Sort by touches (highest first), then user_id.Pattern: UNION vs UNION ALLMediumFree
- Activity streaks as date rangesReturn user_id, start_date, end_date and days (number of distinct days in the streak) for every streak of at least 3 consecutive days in app_opens. Sort by user_id, start_date.Pattern: Gaps and islands · duplicate daysHardPro
- Share of total spendReturn category, total (sum of amount) and pct_of_total (that total as a percentage of all spend, rounded to 1 decimal), largest share first.Pattern: SUM() OVER () · percent of totalMediumPro
- Day-7 retention by install weekGroup players by install week (the Monday of the week of installed_at, as a date). A player is retained if they logged in on the calendar date exactly 7 days after their install date. Leave out players whose day 7 is after 2025-01-31. Return cohort_week, players, retained_d7 and d7_retention_pct (retained as a % of players, rounded to 1 decimal). Sort by cohort_week.Pattern: Calendar-day offsets · LEFT JOIN · cohort cutoffHardPro
Tip: Streaming tables are huge and split by date: practice combining a history table with a daily one.
Sources
Spotify is a trademark of its owner, used here only to identify the company the reports are about.