use db_sql2008
go
select 书名,出版社,SUM(金额) as 总计金额
from tb_BookSell
group by GROUPING sets (书名,出版社)
--等同于
SELECT
Null AS 出版社,
书名,
SUM(金额) AS 总计金额
FROM tb_BookSell
GROUP BY 书名
UNION all
SELECT
出版社,
Null AS 书名,
SUM(金额) AS 总计金额
FROM tb_BookSell
GROUP BY 出版社