Problems / RANGE Frame Rolling Sum / Editorial
RANGE
RANGE BETWEEN INTERVAL 6 DAY PRECEDING AND CURRENT ROW
ROWS and RANGE answer different questions: *how many observations back* versus *how far back in the ORDER BY's units*. They coincide exactly when the series is dense and unique per day — which is why the bug ships: it passes review on tidy test data and breaks the first time a store closes for a holiday. Sparse or irregular time series should default to RANGE+interval (or the spine-join when the engine lacks it). One nuance worth keeping: with duplicate ORDER BY values, RANGE includes all peers — for daily-grain data that's precisely the "whole day counts" semantics you want.
ROWS
Solve RANGE Frame Rolling Sum yourself →