Calculate Moving Average Using SQL/BigQquery

Snippet for calculating moving avg using sql/biguqery

Calculate moving avg using sql/biguqery

AVG(users) OVER (ORDER BY day ROWS BETWEEN 6 PRECEDING AND 0 FOLLOWING) AS moving_avg

What about moving average for different categories? For example, we have date, categories, fee. We would like to calculate the moving avg for each category.

Planted: by ;

Lei Ma (2019). 'Calculate Moving Average Using SQL/BigQquery', Datumorphism, 05 April. Available at: https://datumorphism.leima.is/til/data/bigquery-moving-average/.