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.
Cumulative metrics - SQL Tutorial
From the course: Introduction to SQL Using Google BigQuery
Cumulative metrics
- [Instructor] The next window function we'll cover are cumulative metrics, in particular the Cumulative Sum. The ability to aggregate data, particularly sales data, at a daily or monthly level, and then perform cumulative calculations is very, very useful for all finance and accounting scenarios. This is definitely something we want to keep in our BigQuery toolbox. Cumulative Window Functions usually have a timestamp or date field used in the ORDER BY clause. Generally, we also like to avoid using the descending or DESC sort order when we're relating to any time fields in this case. Pre-aggregating our data will tend to give us the best performance for these sorts of calculations and will also lead to the least risk in the case of data duplicates or other data quality issues. Some use cases within our Wisdom Pets business domain might include calculating the annual product sales and quantity for each month within a…