1

I currently have 2 tables TableA and TableB` both within the same MYSQL Database.

I am trying to find a way to take totals from both tables and add them together to give a definitive total.

The tables are used to record Trades. TableA gives the Trade info and TableB gives deposits and withdrawls.

So to get the total Profit/Loss:

Select SUM(PL) AS PL from TableA

Then I can get the total deposits/Withdralws as:

Select SUM(Deposits) AS Deposits, SUM(Withdraw) AS Withdrawls from TableB`

MY question is... I am looking for a way to display to current balance, essentially SUM(PL) + (SUM(Deposits) - SUM(Withdraw) )

I have looked at the different join options but cannot seem to find one that works.

2
  • @ErgestBasha Thats exactly what Im after. Thanks a lot
    – PaulMcF87
    Jun 7 at 15:07
  • You can simplify that a bit: dbfiddle.uk/…
    – Lennart
    Jun 7 at 16:08

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.