SQL 练习20

  • 查询各科成绩前三名的记录
select a.sid,a.cid,a.score from sc a 
left join sc b on a.cid = b.cid and a.score<b.score
group by a.cid, a.sid,a.score
having count(*)<3
order by a.cid,a.score DESC

image

posted @ 2021-08-20 15:18  弩哥++  阅读(34)  评论(0编辑  收藏  举报