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

相关文章:

  • 2021-09-07
  • 2021-07-18
  • 2022-12-23
  • 2022-12-23
  • 2021-12-02
  • 2022-12-23
  • 2021-10-23
猜你喜欢
  • 2021-11-01
  • 2021-09-11
  • 2021-08-26
  • 2022-12-23
  • 2021-08-21
  • 2021-10-07
相关资源
相似解决方案