A user is active on a day if they have at least one row that day with `minutes` > 0 (NULL or 0 minutes is not activity; duplicate rows count once). For each month: `avg_dau` = average number of active users per day, taken over the days in that month that had at least one active user (ROUND 2); `mau` = distinct active users in the month; `stickiness_pct` = ROUND(100.0 * avg_dau / mau, 1) using the unrounded avg_dau. Return `month` ('YYYY-MM'), `avg_dau`, `mau`, `stickiness_pct`. Order by `month`.
| Column | Type |
|---|---|
| user_id | INTEGER |
| activity_date | DATE |
| minutes | INTEGER |
| user_id | activity_date | minutes |
|---|---|---|
| 1 | 2026-10-01 | 30 |
| 2 | 2026-10-01 | 15 |
| 3 | 2026-10-01 | 5 |
| 1 | 2026-10-01 | 10 |
| 1 | 2026-10-02 | 20 |
| 2 | 2026-10-02 | 25 |
| 1 | 2026-10-03 | 45 |
| 2 | 2026-11-01 | 10 |
| month | avg_dau | mau | stickiness_pct |
|---|---|---|---|
| 2026-10 | 2 | 3 | 66.7 |
| 2026-11 | 1.5 | 2 | 75 |
Solve it in the live editor on this page — run on sample data, then submit against hidden tests.
‹ Merge Overlapping License Periods · Azure Cost Roll-up Through the Resource Tree ›
{{ totalCount }} questions in the style asked at Amazon, Microsoft, Google, Meta, Flipkart and more — {{ hardPct }}% Hard. Write SQL in a real database engine in your browser, run it on sample data, then evaluate against hidden tests.
Company tags show where this type of question is commonly reported in interviews. Questions, data and solutions are written by TechTown.
{{ cur.statement }}
No submissions yet. Press Evaluate to submit your query.
{{ solutionSql }}
{{ out.error }}
You have solved your 3 free questions — nice work! Log in (free) to unlock all 150 questions, keep your streak and appear on the leaderboard.