Streamly: a free sample database for SQL practice
Streamly is a small music streaming app with three and a half months of activity: signups by country and acquisition source, one row per listening session, and paid subscriptions that start and get cancelled. It's built for the product-analytics questions data analysts get asked: active users, retention, conversion and churn.
Tables and columns
A small music streaming app: signups, listening sessions and subscriptions, January to mid-April 2026.
users
300 rowsEveryone who signed up.
- idinteger
- signed_up_ondate
- countrytext
- sourcetextsearch, friend, ad or podcast
plays
2,407 rowsOne row per listening session.
- idinteger
- user_idintegerโ users.id
- played_ondate
- minutesinteger
- devicetextmobile, desktop or tv
subscriptions
100 rowsPaid plans. cancelled_on is NULL while active.
- user_idintegerโ users.id
- started_ondate
- plantextmonthly or yearly
- cancelled_ondate
What the data looks like
The first five rows of each table.
users
| id | signed_up_on | country | source |
|---|---|---|---|
| 1 | 2026-01-01 | BR | podcast |
| 2 | 2026-01-02 | US | ad |
| 3 | 2026-01-02 | DE | search |
| 4 | 2026-01-02 | US | search |
| 5 | 2026-01-03 | US | search |
plays
| id | user_id | played_on | minutes | device |
|---|---|---|---|---|
| 1 | 2 | 2026-01-07 | 62 | tv |
| 2 | 3 | 2026-01-03 | 13 | mobile |
| 3 | 3 | 2026-01-10 | 39 | tv |
| 4 | 3 | 2026-01-22 | 25 | desktop |
| 5 | 3 | 2026-01-25 | 69 | mobile |
subscriptions
| user_id | started_on | plan | cancelled_on |
|---|---|---|---|
| 3 | 2026-01-09 | yearly | 2026-02-12 |
| 6 | 2026-01-09 | monthly | NULL |
| 7 | 2026-01-17 | monthly | 2026-03-15 |
| 19 | 2026-01-25 | yearly | 2026-03-20 |
| 22 | 2026-01-20 | yearly | NULL |
SQL practice questions for this database
Good for: Daily and monthly active users ยท Cohort retention ยท Conversion and churn ยท Date functions ยท Window functions over time. Try them yourself first, then compare.
Signups by acquisition sourceShow a solution
SELECT source, COUNT(*) AS signups FROM users GROUP BY source ORDER BY signups DESC;
Result (PostgreSQL and SQLite, identical): 4 rows
| source | signups |
|---|---|
| search | 97 |
| friend | 91 |
| ad | 57 |
| podcast | 55 |
Listening minutes per deviceShow a solution
SELECT device, SUM(minutes) AS minutes FROM plays GROUP BY device ORDER BY minutes DESC;
Result (PostgreSQL and SQLite, identical): 3 rows
| device | minutes |
|---|---|
| mobile | 68304 |
| desktop | 34714 |
| tv | 9348 |
Share of users who ever subscribedShow a solution
SELECT ROUND(100.0 * COUNT(DISTINCT s.user_id) / COUNT(DISTINCT u.id), 1) AS pct_subscribed FROM users u LEFT JOIN subscriptions s ON s.user_id = u.id;
Result (PostgreSQL and SQLite, identical): 1 row
| pct_subscribed |
|---|
| 33.3 |
Active subscriptions by planShow a solution
SELECT plan, COUNT(*) AS active FROM subscriptions WHERE cancelled_on IS NULL GROUP BY plan;
Result (PostgreSQL and SQLite, identical): 2 rows
| plan | active |
|---|---|
| monthly | 56 |
| yearly | 31 |
Users per countryShow a solution
SELECT country, COUNT(*) AS users FROM users GROUP BY country ORDER BY users DESC, country;
Result (PostgreSQL and SQLite, identical): 5 rows
| country | users |
|---|---|
| US | 125 |
| IN | 52 |
| BR | 46 |
| GB | 45 |
| DE | 32 |
Plays per monthShow a solution
SELECT SUBSTR(CAST(played_on AS TEXT), 1, 7) AS month, COUNT(*) AS plays FROM plays GROUP BY 1 ORDER BY 1;
Result (PostgreSQL and SQLite, identical): 4 rows
| month | plays |
|---|---|
| 2026-01 | 274 |
| 2026-02 | 635 |
| 2026-03 | 1015 |
| 2026-04 | 483 |
Users who never playedShow a solution
SELECT COUNT(*) AS never_played FROM users u WHERE NOT EXISTS (SELECT 1 FROM plays p WHERE p.user_id = u.id);
Result (PostgreSQL and SQLite, identical): 1 row
| never_played |
|---|
| 24 |
The ten heaviest listenersShow a solution
SELECT user_id, SUM(minutes) AS minutes FROM plays GROUP BY user_id ORDER BY minutes DESC, user_id LIMIT 10;
Result (PostgreSQL and SQLite, identical): first 8 of 10 rows
| user_id | minutes |
|---|---|
| 32 | 1357 |
| 43 | 1344 |
| 8 | 1197 |
| 64 | 1185 |
| 177 | 1183 |
| 83 | 1151 |
| 162 | 1146 |
| 122 | 1080 |
Average play length per deviceShow a solution
SELECT device, ROUND(AVG(minutes), 1) AS avg_minutes FROM plays GROUP BY device ORDER BY avg_minutes DESC;
Result (PostgreSQL and SQLite, identical): 3 rows
| device | avg_minutes |
|---|---|
| desktop | 47.4 |
| mobile | 47.1 |
| tv | 41.5 |
Cancelled subscriptions per planShow a solution
SELECT plan, COUNT(cancelled_on) AS cancelled, COUNT(*) AS subscriptions FROM subscriptions GROUP BY plan ORDER BY plan;
Result (PostgreSQL and SQLite, identical): 2 rows
| plan | cancelled | subscriptions |
|---|---|---|
| monthly | 9 | 65 |
| yearly | 4 | 35 |
New users per source and monthShow a solution
SELECT source, SUBSTR(CAST(signed_up_on AS TEXT), 1, 7) AS month, COUNT(*) AS users FROM users GROUP BY source, 2 ORDER BY source, month;
Result (PostgreSQL and SQLite, identical): first 8 of 12 rows
| source | month | users |
|---|---|---|
| ad | 2026-01 | 17 |
| ad | 2026-02 | 12 |
| ad | 2026-03 | 28 |
| friend | 2026-01 | 17 |
| friend | 2026-02 | 37 |
| friend | 2026-03 | 37 |
| podcast | 2026-01 | 14 |
| podcast | 2026-02 | 23 |
Each user's first playShow a solution
SELECT u.id, MIN(p.played_on) AS first_play FROM users u JOIN plays p ON p.user_id = u.id GROUP BY u.id ORDER BY u.id LIMIT 5;
Result (PostgreSQL and SQLite, identical): 5 rows
| id | first_play |
|---|---|
| 2 | 2026-01-07 |
| 3 | 2026-01-03 |
| 4 | 2026-01-04 |
| 6 | 2026-01-04 |
| 7 | 2026-01-05 |
How to load it
SQLite: sqlite3 music-streaming.db < sqlstreak-music-streaming-sample-database.sql
PostgreSQL: psql -d yourdb -f sqlstreak-music-streaming-sample-database.sql
Or skip installing anything and query it in your browser.
Practise on this data every day
sqlstreak's lessons use these tables: five-minute exercises with instant feedback and a streak. No account needed to start.
Start the first lesson