Sign in to run and submit your work
Reading is open to everyone. Running code and saving drafts need an account so your work is yours and comes back on your next visit.
or
CODE WORKSPACE
The growth team tracks daily active profiles and the trailing-7-day active audience, then divides one by the other to get stickiness. netflix_streams has one row per streaming session, so a profile can appear several times a day and on many days.
Return one row per day that has activity, ordered by activity_day.
Result columns · in this order
activity_day | The day being reported. |
dau | Distinct profiles active that day. |
wau_7d | Distinct profiles active in the trailing 7 days. |
stickiness_pct | dau as a percentage of wau_7d. |
How to approach it
Try the running-sum shortcut first and check it against the profiles you can see. Then work out why it fails.
Sample input
| stream_id | profile_id | streamed_on | minutes |
|---|---|---|---|
| 1 | p1 | 2026-03-01 | 45 |
| 2 | p2 | 2026-03-01 | 80 |
| 3 | p1 | 2026-03-01 | 30 |
| 4 | p3 | 2026-03-02 | 120 |
| 5 | p1 | 2026-03-02 | 25 |
| 6 | p2 | 2026-03-03 | 60 |
| 7 | p4 | 2026-03-03 | 90 |
| 8 | p4 | 2026-03-03 | 15 |
| 9 | p1 | 2026-03-04 | 55 |
| 10 | p5 | 2026-03-04 | 40 |
| 11 | p3 | 2026-03-05 | 70 |
| 12 | p6 | 2026-03-05 | 35 |
| 13 | p1 | 2026-03-05 | 20 |
| 14 | p2 | 2026-03-06 | 95 |
| 15 | p7 | 2026-03-06 | 50 |
| 16 | p1 | 2026-03-07 | 65 |
| 17 | p8 | 2026-03-07 | 45 |
| 18 | p3 | 2026-03-07 | 30 |
| 19 | p9 | 2026-03-08 | 110 |
| 20 | p1 | 2026-03-08 | 40 |
| 21 | p2 | 2026-03-08 | 25 |
| 22 | p10 | 2026-03-08 | 75 |
22 rows — scroll inside the table to see them all.
Expected output
| activity_day | dau | wau_7d | stickiness_pct |
|---|---|---|---|
| 2026-03-01 | 2 | 2 | 100 |
| 2026-03-02 | 2 | 3 | 66.7 |
| 2026-03-03 | 2 | 4 | 50 |
| 2026-03-04 | 2 | 5 | 40 |
| 2026-03-05 | 3 | 6 | 50 |
| 2026-03-06 | 2 | 7 | 28.6 |
| 2026-03-07 | 3 | 8 | 37.5 |
| 2026-03-08 | 4 | 10 | 40 |
8 rows — all rows shown.
Constraints
dau is the number of distinct profiles that streamed on that day.wau_7d is the number of distinct profiles that streamed in the 7-day window ending on that day, inclusive. A profile active on three of those days counts once.stickiness_pct is dau over wau_7d as a percentage, rounded to 1 decimal place.dau.activity_day.Worked example
On 2026-03-08 the distinct profiles active that day are p9, p1, p2 and p10 — a dau of 4. Across the seven days from 2 March to 8 March, ten distinct profiles streamed, so wau_7d is 10 and stickiness is 40.0%.
The natural move is SUM(dau) OVER (ORDER BY activity_day ROWS BETWEEN 6 PRECEDING AND CURRENT ROW). That gives 18, not 10, because p1 streamed on six of those days and is counted six times. Distinct counts are not additive: seven daily uniques cannot be combined into a weekly unique without going back to the underlying rows.
What this tests
That COUNT(DISTINCT ...) does not compose over a window frame. Recognising which measures are additive and which are not is the difference between a metric that is wrong by 80% and one that is right.
Submit for review to find out what your query gets right, what it gets wrong, and how it compares with the best working query for this exercise.
This scenario runs a full workspace — editor, canvas and results side by side. It needs a laptop or desktop to be usable. Open this page on a bigger screen to start building.