这是我的第一个小组,我尝试执行以下操作:
这是我所拥有的,但它没有编译:
SELECT SUM(SUM(Amount) + SUM(TaxAmount)) AS Total
FROM Truck.PpsTransaction
GROUP BY ReferenceNumber, Branch, AccountNumber
我做错了什么?
答案 0 :(得分:2)
SELECT ReferenceNumber, Branch, AccountNumber, SUM(Amount + TaxAmount) AS Total
FROM Truck.PpsTransaction
GROUP BY ReferenceNumber, Branch, AccountNumber
答案 1 :(得分:0)
在这种情况下,Rollup应该可以正常运行:
SELECT ReferenceNumber, Branch, AccountNumberReferenceNumber,
SUM(Amount) GroupAmount, Sum(TaxAmount), GroupTax,
SUM(Amount + TaxAmount) AS GroupTotal
FROM Truck.PpsTransaction
GROUP BY ReferenceNumber, Branch, AccountNumber WITH ROLLUP