Moving average

A moving average smooths a series by averaging the values of a sliding window, for example the last 7 days, with AVG(...) OVER (ORDER BY ... ROWS BETWEEN 6 PRECEDING AND CURRENT ROW). The first rows have an incomplete window, which must be handled or flagged. Missing days skew a row-based window.

Example

AVG(ventes) OVER (ORDER BY jour ROWS BETWEEN 6 PRECEDING AND CURRENT ROW)

Related concepts

The whole glossary