mysql中分组之后取每个组的前三个
时间:2022-03-15 08:32
SELECT * FROM course a WHERE
3>(SELECT COUNT(*) FROM course WHERE coursename=a.coursename and score>a.score)
ORDER BY a.coursename,a.score DESC;
取每一条记录,判断同一个班级,大于当前成绩的同学是不是小于2个人。
时间:2022-03-15 08:32
SELECT * FROM course a WHERE
3>(SELECT COUNT(*) FROM course WHERE coursename=a.coursename and score>a.score)
ORDER BY a.coursename,a.score DESC;
取每一条记录,判断同一个班级,大于当前成绩的同学是不是小于2个人。