Quantcast
Channel: Questions in topic: "common-table-expression"
Viewing all articles
Browse latest Browse all 5

How to calculate balance on the bases of previous record?

$
0
0
Hi All, i am currently facing an issue and hope that someone will help me. here is the scenario. I have a simple table. Member Table ================
Member_id Member Name Opening Balance Opening Balance Type
1 David 5000 Debit
Transaction Table =================
Transaction_IdTransaction DateMember_idDescriptionDebitCredit
110/01/20111Deposit5000
210/02/20111WidDrawl01000
310/03/20111Deposit5000
410/04/20111WidDrawl08000
Now what i need to show the Balance after each entry and its Type. The final result will be look like this. Transaction Details View ===================================
Transaction_IdTransaction DateMember_idDescriptionDebitCredit Balance Balance Type
110/01/20111Deposit50005500 Debit
210/02/20111WidDrawl010004500 Debit
310/03/20111Deposit50005000 Debit
410/04/20111WidDrawl080003000 Credit
How can i create this view? the final balance is prepared by using the opening balance from the members table and then each calculation is made by the balance of previous record to the next and balance type is changed accordingly. I hope that some expert will help.

Viewing all articles
Browse latest Browse all 5

Latest Images

Trending Articles





Latest Images