I am struggling to work out the correct MySQL syntax to add the result of two queries. The queries draw call records from a table, both generate a single figure result, I need to add them together. I’m sure this can be done with a subquery but I can’t seem to get the syntax right.
Here are the queries:
SELECT SUM(costres) - SUM(costadmin)
FROM call_history, client
WHERE MONTH(start) = 3 AND YEAR(start) = 2012
AND call_history.client_reseller_id = client.id
AND client.charging_identifier <> 100000
AND client.charging_identifier <> 999999;
SELECT SUM(costcl) - SUM(costadmin)
FROM call_history, client
WHERE MONTH(start) = 3 AND YEAR(start) = 2012
AND call_history.client_reseller_id = client.id
AND client.charging_identifier = 100000
AND client.charging_identifier <> 999999;
As I said, I know this is simple, but I just can’t seem to get my head around subquery syntax in MySQL!
Thanks in advance
George
How about –