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,排名
本文来自博客园,作者:弩哥++,转载请注明原文链接:https://www.cnblogs.com/bangbangzoutianya/p/15166239.html