From the course: SQL Tips and Tricks for Data Science

Unlock the full course today

Join today to access over 23,100 courses taught by industry experts.

Rolling calculations

Rolling calculations

- [Instructor] So now let's talk about rolling calculations. Rolling calculations are a method of applying an aggregation over a specified time period. Now, they're really useful when looking across time periods as well. Typically, high-level time periods like months, quarters, or even years. When analyzing data over time, it's common to want to create moving calculations. The most common type is a moving average. This calculation may help you smooth out variability that may occur due to anomalies in your data. The common example here would be to look at a three month moving average of sales. Three months is a good time period for most companies, as it aligns with the quarterly sales cycles and smooths out any individual bad or good months. Another common reason to use moving calculations is to create year-to-date totals. Running totals are a great way to look at how the year is doing compared to the last few and help…

Contents