🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: alt.comp.databases.mysql
1 messages
1 total messages Started by Paaro Sat, 09 Apr 2022 13:45
Regd Merging These 2 MySql Queries into 1
#1
Author: Paaro
Date: Sat, 09 Apr 2022 13:45
18 lines
1956 bytes
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.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads