SELECT dbo.items.NAME,
CONVERT(VARCHAR(20), dbo.warehouse.date, 101)AS Date,
Sum (dbo.warehouse.debit) AS Quantity
FROM dbo.warehouse
INNER JOIN dbo.items
ON dbo.warehouse.businessunitid = dbo.items.businessunitid
AND dbo.warehouse.itemid = dbo.items.itemid
GROUP BY dbo.items.NAME,
CONVERT(VARCHAR(20), dbo.warehouse.date, 101)
SQL加入查詢來獲取項目名稱,日期和借方餘額的總和,其中借方差額不等於0SQL加入查詢以獲取項目名稱,日期和借方餘額不等於0的借方餘額總和?
要小心,要匹配的問題應該是'HAVING Sum(w.debit)<> 0;' – danihp
@danihp。 。 。這是一個好點。 –