Skip to content
Advertisement

Join and calculate between 3 queries

I have 3 sql queries as follow with different conditions and rules but giving the same output:

Query1:

sample output

Query2:

sample output

Query3:

sample output

and my final output.. I would like to sum(Amount1+Amount2+Amount3) and group by PaymentDate.

I’ve tried the following but it doesn’t work

and I am expecting results like this:

expected output

Life would be much more easier if it can work that way -_- Appreciate your kind help and assistant. Thanks

NOTE I update the query for better understanding as for why I need to all all the amount. I plan not to change the main query as it will be use by other function. So i need to come up with new query to get the total of all 3 queries..

Advertisement

Answer

Your 3 queries is stranger, could it run successfully while using GROUP BY without any aggregate function?

Your expected query should has structure like this:

So for your edited question, the final query would be:

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement