CREATE TABLE #Product (ProductId INT, ProductName Varchar(500), Price MONEY)
INSERT INTO #Product (ProductId ,ProductName,Price)
VALUES(1, 'Test1', 12000),
(2, 'Test2', 18000),
(3, 'Test3', 25000),
(4, 'Test4', 15000),
(1, 'Test4', 15000)
SELECT ProductId ,ProductName, SUM(Price) AS Price
FROM #Product Group By
GROUPING SETS((ProductId), (ProductName), ())
SELECT ProductId ,ProductName, SUM(Price) AS Price
FROM #Product Group By
GROUPING SETS((ProductId, ProductName), ())
这两者有什么区别?以及在哪里使用第一个和第二个