0

I would like to SUM two fileds from different rows from the same table but I don't know how to do that.

E.g.

BillingTransactionsIndex CreateDate UserType UserIndex TransType Reference Total Balance
2 6/5/2008 15:02 1 51 1 150 -288.2 -288.2
5 6/8/2008 11:55 1 51 1 157 -1.58674 -289.787

In the table above I want SUM fields Total and Balance for the first row and the the next row SUM 2nd row Total with 1st row Balance

Please help

Thanks

2
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by tesuji
0

I want this

Total Balance
row 1 90 90
row 2 23 113
row 3 15 128
row 4 20 148

In row 2 to get the balance I SUM Balance(90) of row 1 with Total(23) of row 2 to get Balance (113) of row 2. Same thing is done for the next row by adding with Balance of previous row

0

Hi tkotey

Similar problem we have discussed on http://www.daniweb.com/forums/thread127644.html.
you may investigate SQL code from posts #5 and #7 where I gave solutions on how to compute balance values from consecutive rows. You can adapt that code so it fits your specific requirements. If you have further problems we can discuss them here.

krs,
tesu

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.