商品按销售量排序后台java如何实现
表如何设计方便selectg.*,t.销量fromgoodsasg,(selecto.goods_id,sum(o.销量)as销量fromorder_goodsasogr...
表如何设计方便
select g.*, t.销量
from goods as g, (select o.goods_id, sum(o.销量) as 销量 from order_goods as o group by o.goods_id) as t
where g.goods_id = t.goods_id
order by t.销量 desc
按这个的话缺点是销量为0的不显示,如何优化 展开
select g.*, t.销量
from goods as g, (select o.goods_id, sum(o.销量) as 销量 from order_goods as o group by o.goods_id) as t
where g.goods_id = t.goods_id
order by t.销量 desc
按这个的话缺点是销量为0的不显示,如何优化 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询