Create table Inventory(Item char(10),spec char(10),sprice decimal)
insert into Inventory values ('DVD','步步高',2000)
insert into Inventory values ('PC','LG',3000)
insert into Inventory values ('PC','TCL',2000)
insert into Inventory values ('PC','三星',2000)
--ROLLUP是按照group by后的字段依次汇总,
--cube是对GROUP BY 后的所有列都汇总
SELECT Item, spec,sum(sprice)
from Inventory
group by Item,spec
with rollup
SELECT Item, spec,sum(sprice)
from Inventory
group by Item,spec
with cube
insert into Inventory values ('DVD','步步高',2000)
insert into Inventory values ('PC','LG',3000)
insert into Inventory values ('PC','TCL',2000)
insert into Inventory values ('PC','三星',2000)
--ROLLUP是按照group by后的字段依次汇总,
--cube是对GROUP BY 后的所有列都汇总
SELECT Item, spec,sum(sprice)
from Inventory
group by Item,spec
with rollup
SELECT Item, spec,sum(sprice)
from Inventory
group by Item,spec
with cube