There are there tables the below image.
My question is retrieve from each customers and get the sum of Invoice total due, Invoice Total balance in invoice table and return cheque total due and return cheque total balance in return cheque table…
I wanted the answer like below image from the above 3 table using inner join
Please help me thank you.
Best Answer
This may not be the best way to do this but it will work.
And of course you could change the subqueries into CTEs. But basically you are going to collect the data pre join since otherwise you are probably going to get bad data (Client 2 for example will have Invoice info that is twice as large and ReturnCheque that is 3 times as large.)