Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cumulative totals using T-SQL

Status
Not open for further replies.

anumala28

Programmer
Jun 28, 2002
87
0
0
US
Hi,

How do i crete cumulative totals using T-SQL. Please let me know the steps.
Thanks

 
A cumulative total of what, from what source and based on what?

Please provide a reasonable level of information about what you are trying to achieve else you're unlikely to get a response.

Rhys
The use of COBOL cripples the mind; its teaching should, therefore, be regarded as a criminal offense Edsgar Dijkstra

Church of the Flying Spaghetti Monster
 
Ex:
I have one table Employee. In this table Salary column has some values. 400,300,100. I need to write SQL statement to get cumlative salary.

Out put shoule like this:

empNo Salary CumTotal
101 400 400
102 300 700
103 100 800
 
Code:
SELECT Employee.EmpNo, Employee.Salary,
       SUM(Empl.Salary) AS CumTotal
FROM Employee
INNER JOIN Employee Empl ON Employee.EmpNo >= Empl.EmpNo
GROUP BY Employee.EmpNo, Employee.Salary
ORDER BY EmpNo

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
MVP VFP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top