20金币
最佳答案CREATE VIEW UnitSalesView AS
SELECT
A.UnitID,
A.Balance,
COALESCE(SUM(B.SalesQuantity), 0) AS TotalSalesQuantity,
COALESCE(SUM(C.ReceiptAmount), 0) AS TotalReceiptAmount
FROM
Units A
LEFT JOIN
Sales B ON A.UnitID = B.UnitID AND B.SalesDate BETWEEN 'startDate' AND 'endDate'
LEFT JOIN
Receipts C ON A.UnitID = C.UnitID AND C.ReceiptDate BETWEEN 'startDate' ...
| |
| |
| |
| |
| |
| |
| |
| |