清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
DECLARE @T TABLE(名称 VARCHAR(1) , 出版商 VARCHAR(10), 价格1 INT, 价格2 INT) INSERT @T SELECT 'a', '北京', 11, 22 UNION ALL SELECT 'a', '四川', 22, 33 UNION ALL SELECT 'b', '四川', 12, 23 UNION ALL SELECT 'b', '北京', 10, 20 UNION ALL SELECT 'b', '昆明', 20, 30 SELECT 名称, 出版商, SUM(价格1) AS 价格1, SUM(价格2) AS 价格2, GROUPING(名称) AS CHECK名称, GROUPING(出版商) AS CHECK出版商 FROM @T GROUP BY 名称,出版商 WITH CUBE SELECT 名称, 出版商, SUM(价格1) AS 价格1, SUM(价格2) AS 价格2 FROM @T GROUP BY 名称,出版商 WITH ROLLUP