Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: Enterprise
Expertise: Intermediate
Dec 14, 2001



Application Security Testing: An Integral Part of DevOps

Handling Cumulative Totals in T-SQL

Suppose you have a table:
select * from tblTest

Name	Amount
---	------
A	10
B	20
c	40
D	50
E	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 <= t1.Name ) AS
FROM tblTest AS t1


Name	Amount	Total
---	------	-----
A	10	10
B	20	30
c	40	70
D	50	120
E	30	150
Harinatha Reddy
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date