From the course: Introduction to SQL Using Google BigQuery

Unlock the full course today

Join today to access over 24,900 courses taught by industry experts.

Moving averages

Moving averages

- [Instructor] The final window function we'll be covering is the moving average calculation. This type of calculation is seen in almost every domain and can be used with both historical data as well as live streaming data in real time systems. Moving averages or other metrics will usually have a time or date field used directly in the ORDER BY expression with the OVER clause for the window function implementation. The window frame mode is usually set to RANGE, so we can make comparisons with the changing date values within the ORDER BY expression. This is the key difference for moving average calculations over the previous window functions we've seen before. In this case, we'll need to define the frame clause within the required window function OVER clause as we determine how large our sliding time window should be for our specific metrics. Some use cases for our Wisdom Pets case study could include calculating the daily moving…

Contents