This blog post explains how to calculate running totals in SQL Server, why you would use them and provides a breakdown of the syntax
What is a running total?
A running total is a cumulative sum that takes all the values of a sequence and adds them together. It is typically used in data analysis to calculate cumulative results over a period of time, such as tracking total sales over the past year.
While the basic SQL syntax is straightforward, our SQL consultants often help teams move beyond simple sums to architect robust, high-performance reporting engines. If your data requirements go beyond basic aggregates, our SQL consultancy can help you ensure your environment is optimised for growth and complex logic. The ability to accurately track these lead and lag relationships in your data is vital for businesses that need to make decisions based on up-to-date information.
Example use case
An example of a use case is to calculate a predicted closing inventory. As part of an inventory forecasting process. Taking into account predicted sales and expected deliveries.
Why would you want to calculate a running total?
How to calculate a running total in SQL Server



Running Totals in SQL Server – Conclusion
Subscribe to our channel to see more Excel Timesavers
Select Distinct YouTube Channel
Our Business Analytics Timesavers are selected from our day to day analytics consultancy work. They are the everyday things we see that really help analysts, SQL developers, BI Developers and many more people.
Our blog has something for everyone, from tips for improving your SQL skills to posts about BI tools and techniques. We hope that you find these helpful!
IIf your cumulative sum calculations needs go beyond basic Running Totals functions, our SQL Server Consulting can help you architect high-performance environments and complex aggregation logic.
Book a 30-minute FREE Teams call with Simon Harrison to discuss your specific business goals and ensure your SQL setup is optimised for growth without unnecessary overhead.

