Calculate Moving Average Using SQL/BigQquery

#Data Warehouse #Big Query #SQL

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.

Published: by ;

Table of Contents

Current Ref:

  • til/data/bigquery-moving-average.md