I have the following table that has a list of transactions
ID FromID ToId AMOUNT
1 1 2 10
2 1 3 10
4 1 4 10
5 3 2 3
6 4 2 2
7 4 2 1
8 2 4 2
I'd like to know the best/most effecient way to get a users balance. The balance would be the sum of the amount the user has been given (where ID is ToId) minus the sum of the amount the user has given out (where ID is FromId)
Any ideas?
Thanks in advance.
James