Problems / DAU/WAU Stickiness / Editorial
calendar c JOIN daily d ON d.activity_day BETWEEN c.day - INTERVAL 6 DAY AND c.day
COUNT(DISTINCT ...)
activity_day = c.day
MIN(day) + 6
Window functions can roll sums and counts, but not distinct counts — COUNT(DISTINCT) OVER (... ROWS BETWEEN ...) simply doesn't exist, because distinctness can't be maintained incrementally as a frame slides. The general-purpose escape hatch is the spine range join: materialize each (day, window-member) pair, then use ordinary grouped aggregation where DISTINCT works fine. It costs a controlled fan-out (×7 here) and buys full aggregate generality — the trade every rolling-distinct metric makes.
COUNT(DISTINCT) OVER (... ROWS BETWEEN ...)
Solve DAU/WAU Stickiness yourself →