sqlstreak

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.

Download .sql (PostgreSQL + SQLite) SQLite .db CSV (zip) Query it online3 tables ยท 2,807 rows ยท CC BY 4.0

Tables and columns

A small music streaming app: signups, listening sessions and subscriptions, January to mid-April 2026.

Streamly: tables, keys and how they connectplays๐Ÿ”‘ iduser_idplayed_onminutesdeviceusers๐Ÿ”‘ idsigned_up_oncountrysourcesubscriptionsuser_idstarted_onplancancelled_on
๐Ÿ”‘ primary key ยท blue columns point at another table (foreign keys); the arrows show where.

users

300 rows

Everyone who signed up.

  • idinteger
  • signed_up_ondate
  • countrytext
  • sourcetextsearch, friend, ad or podcast

plays

2,407 rows

One row per listening session.

  • idinteger
  • user_idintegerโ†’ users.id
  • played_ondate
  • minutesinteger
  • devicetextmobile, desktop or tv

subscriptions

100 rows

Paid 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

idsigned_up_oncountrysource
12026-01-01BRpodcast
22026-01-02USad
32026-01-02DEsearch
42026-01-02USsearch
52026-01-03USsearch

plays

iduser_idplayed_onminutesdevice
122026-01-0762tv
232026-01-0313mobile
332026-01-1039tv
432026-01-2225desktop
532026-01-2569mobile

subscriptions

user_idstarted_onplancancelled_on
32026-01-09yearly2026-02-12
62026-01-09monthlyNULL
72026-01-17monthly2026-03-15
192026-01-25yearly2026-03-20
222026-01-20yearlyNULL

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

sourcesignups
search97
friend91
ad57
podcast55
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

deviceminutes
mobile68304
desktop34714
tv9348
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

planactive
monthly56
yearly31
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

countryusers
US125
IN52
BR46
GB45
DE32
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

monthplays
2026-01274
2026-02635
2026-031015
2026-04483
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_idminutes
321357
431344
81197
641185
1771183
831151
1621146
1221080
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

deviceavg_minutes
desktop47.4
mobile47.1
tv41.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

plancancelledsubscriptions
monthly965
yearly435
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

sourcemonthusers
ad2026-0117
ad2026-0212
ad2026-0328
friend2026-0117
friend2026-0237
friend2026-0337
podcast2026-0114
podcast2026-0223
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

idfirst_play
22026-01-07
32026-01-03
42026-01-04
62026-01-04
72026-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.

License

Free to use in courses, tutorials, blog posts and interviews under CC BY 4.0. Please credit it with a link: Data: sqlstreak.com/datasets/music-streaming

Teaching with it? Tell me and I'll help.

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

Guides that use it

Practice on it

More sample databases