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_Id | Transaction Date | Member_id | Description | Debit | Credit |
1 | 10/01/2011 | 1 | Deposit | 500 | 0 |
2 | 10/02/2011 | 1 | WidDrawl | 0 | 1000 |
3 | 10/03/2011 | 1 | Deposit | 500 | 0 |
4 | 10/04/2011 | 1 | WidDrawl | 0 | 8000 |
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_Id | Transaction Date | Member_id | Description | Debit | Credit | Balance | Balance Type |
1 | 10/01/2011 | 1 | Deposit | 500 | 0 | 5500 | Debit |
2 | 10/02/2011 | 1 | WidDrawl | 0 | 1000 | 4500 | Debit |
3 | 10/03/2011 | 1 | Deposit | 500 | 0 | 5000 | Debit |
4 | 10/04/2011 | 1 | WidDrawl | 0 | 8000 | 3000 | 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.