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 - SQL Tutorial
From the course: SQL Tips and Tricks for Data Science
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
Retrieve data using SQL4m 18s
-
(Locked)
Join tables5m 44s
-
(Locked)
Filter data5m 33s
-
(Locked)
Aggregate data6m 29s
-
(Locked)
Window functions1m 54s
-
(Locked)
Subqueries4m 16s
-
(Locked)
Rolling calculations4m 48s
-
(Locked)
Analyze employee data4m 18s
-
(Locked)
Date and time functions5m 11s
-
(Locked)
Common table expressions5m 55s
-
(Locked)
Year-over-year calculations3m 26s
-
(Locked)
Finding ranks4m 9s
-
-