devxlogo

Handling Cumulative Totals in T-SQL

Handling Cumulative Totals in T-SQL

Suppose you have a table:

 select * from tblTestName	Amount---	------A	10B	20c	40D	50E	30

The following single SELECT query can be used to calculate cumulative totals:

 --//////////////////////////////////////SELECT t1.Name, t1.Amount,(SELECT SUM(t2.Amount ) FROM tblTest AS t2 WHERE t2.Name 

devx-admin

Share the Post: