sql查询2

查询各科成绩前三名的记录:(不考虑成绩并列情况

sc表,student表,course表

比如某一科的前三名

 

selcet score ,c_id from sc where c_id=1 order by score limit0,3;

 

于是

select  from sc  as s1 where s1.score in
(select score from sc where s1.c_id=c_id group by c_id order by score desc limit0,3);

但是这个出了问题,limit 不能有in,看网上说法可以再套一个select,但是有个问题是s1.c_id不认识了

用top 3在mysql又不能用

 

原文地址:https://www.cnblogs.com/bashala/p/3604348.html