mysql分组后取最新的一条记录

发布时间: 2023-11-21 13:07 阅读: 文章来源:1MUMB4729PS
1、mysql分组取每组前三条记录

#根据订单号(order_no)分组,每个订单取3个订单明细

select *FROM ( select *, ROW_NUMBER() OVER (PARTITION BY order_no ORDER BY create_time) AS row_num FROM order_goods_detail ) AS subqueryWHERE row_num
•••展开全文