Code:
data in myTable
j  m1 m1Bs  m2  m2Bs
1  2   100  1   -100 
2  2   220  3   -120 
3  4    40  1   -140 
4  2   520  6   -300 
5  1   -90  4    -10 
6  5    60  4    -70
I have data in myTable like the above.

J represents Journal
M represents Member
Bs represents Balance


The table has 6 members at the moment.
1,2,3,4,5 and 6 in m1 column or m2 column.


The st member "1" is in m2 column of the 1st record, m2 column of the 3rd record and m1 column of the 5th record.

I am interested in the 5th record because it's the latest record.
So the balance of the current state of the 1st member "1" is -90.

For the 2nd member "2",
the balance of the current state of the 2nd member "2" is 520.

The balance of the current state of the 3rd member "3" is -120.

The balance of the current state of the 4th member "4" is -70.

The balance of the current state of the 5th member "5" is 60.

The balance of the current state of the 6th member "6" is -300.

I like to know the sum of all member's balance.

It's 0 ;-90+520-120-70+60-300."



I like to get the sum "0" with SQL.

The following would-be coed doesn't work correctly, but I hope it shows what I want.
Code:
would-be code
select sum(m1Bs, m2Bs) as the_sum_of_final_balance 
from journal
where group by m1 or m2

target result

0
Actually the target result is always "0." because the table records give and take of each member's transaction. It's like zero sum game.

If the member "2" give 100 dollars to the member "1" in the 1st record, the balance of the member 2 will be 100 dollars and the balance of the member 1 will be -100 dollars.

But I need the target result 0 with SQL for data verification.
That is if the target result is 0, it is saying the data is correct, if the target result is not 0, it is saying something wrong in the data of the table.