If you want to avoid using Union or Union ALL (perhaps for reasons of efficiency), then the following works:
SELECT (1.Qty+2.Qty) AS total_qty FROM (SELECT SUM(Qty) Qty FROM MC) 1, (SELECT SUM(Qty) Qty FROM Amex) 2;
Here is an example if you want to expand it to include the Group By clause. Say we have Cust_ID on MC and Amex to identify the customer who placed each order, and we want to know the amounts for each customer. Then the code will look like this:
SELECT COALESCE(1.Cust_ID, 2.Cust_ID) Cust_ID, (1.Qty+2.Qty) AS total_qty FROM (SELECT Cust_ID, SUM(Qty) Qty FROM MC GROUP BY Cust_ID) 1 FULL OUTER JOIN (SELECT Cust_ID, SUM(Qty) Qty FROM Amex GROUP BY Cust_ID) 2 ON 1.Cust_ID = 2.Cust_ID;
If the Customer table exists in the database, this can be simplified to:
SELECT c.Cust_ID, (1.Qty+2.Qty) AS total_qty FROM Customer c LEFT JOIN (SELECT Cust_ID, SUM(Qty) Qty FROM MC GROUP BY Cust_ID) 1 ON 1.Cust_ID = c.Cust_ID LEFT JOIN (SELECT Cust_ID, SUM(Qty) Qty FROM Amex GROUP BY Cust_ID) 2 ON 2.Cust_ID = c.Cust_ID;
source share