正文:
SELECT t.*, MAX(t.score) maxScore FROM (SELECT * FROM student ORDER BY score DESC LIMIT 1000) t GROUP BY t.student_id
LIMIT 1000:MySQL分組查詢時默認按照id從小到大的順序排列會讓自定義的排序,所以里面加上LIMIT 固定住排序。//TODO 待研究
參考博客:
mysql分組后獲取每個組排序后的第一條數據(整行) - persistence勿忘初心 - CSDN博客
https://blog.csdn.net/persistencegoing/article/details/92764058