Query for running total in SQL Server





4.00/5 (1 vote)
Using window functions (partition by) will speed up the process:SELECT Val, SUM(Val) OVER (Partition BY [YourPartitionValue] Order BY [OrderColumn] as CumulativeSumFROM [Table]
Using window functions (partition by) will speed up the process:
SELECT Val,
SUM(Val) OVER (Partition BY [YourPartitionValue]
Order BY [OrderColumn] as CumulativeSum
FROM [Table]