Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Regd Merging These 2 MySql Queries into 1

0 views
Skip to first unread message

Paaro

unread,
Apr 9, 2022, 9:45:57 AM4/9/22
to
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.
0 new messages