一个关于SQL中使用group by SUM求和的问题

2024-12-30 17:21:04
推荐回答(1个)
回答1:

select top 10 商品编号 = b.goodsId,商品名称 = b.goodsName,销售数量 = sum(c.quantity)
from GoodsType a join GoodsInfo b on a.typeId = b.typeId
join OrderGoodsInfo c on b.goodsId = c.goodsId
where a.typeName = '野营用品'group by b.goodsId,b.goodsName order by c.quantity desc
go