Query for running total in SQL Server






3.33/5 (6 votes)
Calculate running total or cumulative sum from a table in a SQL Server database.
SELECT Field1, (SELECT SUM(Field1) FROM [Table] WHERE Field1 <= t.Field1) AS CumulativeSum
FROM [Table] AS t
3.33/5 (6 votes)
Calculate running total or cumulative sum from a table in a SQL Server database.
SELECT Field1, (SELECT SUM(Field1) FROM [Table] WHERE Field1 <= t.Field1) AS CumulativeSum
FROM [Table] AS t