我希望能夠從兩個SELECT查詢中獲取在SUM()中生成的兩個值,並減去這些值以獲得結果( OutstandingFunds)。MySQL - 希望減去兩個SELECT語句中的兩個SUM()值
這是我的兩個SELECT查詢:
聲明(1):
SELECT SUM(Cf.Amount) AS ClearedFunds
FROM (
SELECT Amount FROM PAYMENT1 WHERE `Status` = "Cleared"
UNION ALL
SELECT Amount FROM PAYMENT2 WHERE `Status` = "Cleared"
UNION ALL
SELECT Amount FROM PAYMENT3 WHERE `Status` = "Cleared") AS Cf;
聲明(2):
SELECT SUM(Price) AS TotalSales
FROM PROPERTY
WHERE Status = 「Sold」;
謝謝您的時間
感謝。它非常完美! :) – Steve 2013-02-13 01:57:48