mysql数据库使用group by 统计数量后再进行排序
SELECT shop_id,count(id) as order_total FROM `qipa_member_order` where qipa_activity_id = 250 GROUP BY shop_id ORDER BY order_total desc

本文介绍如何在MySQL中使用group by子句结合count函数来统计特定字段的数量,并通过order by子句按统计结果进行降序排序。示例展示了如何在qipa_member_order表中,针对shop_id进行分组,统计每个店铺的订单总数。
SELECT shop_id,count(id) as order_total FROM `qipa_member_order` where qipa_activity_id = 250 GROUP BY shop_id ORDER BY order_total desc


被折叠的 条评论
为什么被折叠?