Mysql分组排序求topN表结构 按照grp分组,按照num排序,每组取top3,输出结果如下: 源代码12345678SELECT * FROM score AS t3WHERE ( SELECT COUNT(*) FROM score AS t1 LEFT JOIN score AS t2 ON t1.grp = t2.grp AND t1.num < t2.num) < 3ORDER BY t3.grp ASC,num DESC;Mysql上一篇Mysql事务实现原理下一篇mysql的锁机制 相关推荐 2020-01-10Mysql事务实现原理 2020-01-06mysql的锁机制