我希望能够从两个 SELECT 查询中获取我在 SUM() 中生成的两个值并减去这些值以获得结果(OutstandingFunds)。
这是我的两个 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”;
感谢您的时间