Paaro
2022-04-09 15:24:02 UTC
Hi
I have following two SQL queries to execute in mySQL.
SELECT total(amount) as total_receipts FROM receipts WHERE torderid = 101
SELECT total(amount) as total_refunds FROM refunds WHERE torderid = 101
I get following below values using these two above queries
total_receipts
total_refunds
Now I need to calculate net_receipts as below.
net_receipts = total_receipts - total_refunds
Is there way to get total_receipts, total_refunds and net_receipts by merging the above two queries into a single SQL query?
Please help.
I have following two SQL queries to execute in mySQL.
SELECT total(amount) as total_receipts FROM receipts WHERE torderid = 101
SELECT total(amount) as total_refunds FROM refunds WHERE torderid = 101
I get following below values using these two above queries
total_receipts
total_refunds
Now I need to calculate net_receipts as below.
net_receipts = total_receipts - total_refunds
Is there way to get total_receipts, total_refunds and net_receipts by merging the above two queries into a single SQL query?
Please help.