7-Day Active User Rolling Metric
Problem
**[Widely asked at Facebook, Twitter]**
A product team tracks daily active users (DAU). For each day in the dataset,
compute the **7-day rolling unique user count**: how many distinct users were
active in the 7-day window ending on (and including) that day.
This metric — also called WAU (weekly active users) smoothed daily — shows
whether growth is real or just a one-day spike.
Return `window_end_date` and `wau_7d`, ordered by date.
Tables
Example rows — the live problem includes the full dataset.
| activity_id | user_id | active_date |
|---|
Expected output
Your answer should return 8 rows with the columns window_end_date, wau_7d.
Starter code (SQL)
SELECT *
FROM user_activity;Solve this SQL question free
Write SQL and run it instantly in your browser — even on your phone. No signup needed to try.
Solution & explanation
Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.
Sign up free to unlock