Problems / Day-1 / Day-7 Retention / Editorial
d1.activity_day = signup_date + INTERVAL 1 DAY
d7.activity_day = signup_date + INTERVAL 7 DAY
COUNT(DISTINCT dN.user_id)
COUNT(DISTINCT c.user_id)
Bounded retention ("active on day N") is an equality join against a shifted key, which is both its power and its trap. Power: no window functions, no ranges — one deduped activity table serves every N. Trap: with the activity table *not* deduped, the two LEFT JOINs multiply (a user with 3 events on D1 and 2 on D7 yields 6 rows), silently corrupting COUNT(*)-style denominators. Dedupe-then-join is the discipline; DISTINCT counts everywhere are the seatbelt.
COUNT(*)
Solve Day-1 / Day-7 Retention yourself →