SQL对商品进行分类,且统计各类别销售出的总数量。

2024-11-28 02:45:21
推荐回答(2个)
回答1:

select DB_KC_XS.SP_Name,DB_KC_XS.SP_Price,sum(DB_KC_XS.SP_Num) as sp_num,DB_LB.LB_MC from DB_KC_XS,DB_LB where DB_KC_XS.LB_ID=DB_LB.LB_ID group by DB_KC_XS.SP_Name,DB_KC_XS.SP_Price,DB_LB.LB_MC order by SP_Num desc
而且,老兄, 铅笔 应该是
铅笔 2 3 办公用品

回答2:

select DB_KC_XS.SP_Name,avg(DB_KC_XS.SP_Price) as SP_Price,sum(DB_KC_XS.SP_Num) as SP_Num,DB_LB.LB_MC from DB_KC_XS,DB_LB where DB_KC_XS.LB_ID=DB_LB.LB_ID group by DB_KC_XS.SP_Name,DB_LB.LB_MC order by SP_Num desc