题目:按各科成绩进行排序,并显示排名
分析:这题目我自己不会做,看答案的 ,哈哈哈哈
sql:
SELECT a.courseid,a.studentid,a.score,COUNT(b.score)+1 AS rank FROM student_score a
LEFT JOIN student_score b ON a.score < b.score AND a.courseid = b.courseid
GROUP BY a.courseid, a.studentid,a.score ORDER BY a.courseid,rank ASC;
运行: