Click here to Skip to main content
15,896,269 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have table like

id credit

1 1000

2 2000

3 3000

i need a result set like the below

id credit balance

1 1000 1000

2 2000 3000

3 3000 6000


I tried with this query

Select t1.id ,t1.credit),t1.credit+t2.credit, from table1 t1 Inner JOIN table1 t2 ON t1.ID = t2.id - 1
Posted

What you want is called running total. It is not that simple, but can be achieved. Look here: http://www.sqlteam.com/article/calculating-running-totals[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900