SQL 练习18

  • 按各科成绩进行排序,并显示排名, Score 重复时保留名次空缺
SELECT t.cid,t.sid,t.score ,COUNT(t1.score)+1 as 排名 from sc as t 
LEFT JOIN SC as t1 ON t.cid = t1.CId AND t.score < t1.score
GROUP BY t.cid,t.sid,t.score ORDER BY t.cid,排名

image

posted @ 2021-08-20 14:12  弩哥++  阅读(39)  评论(0编辑  收藏  举报