随笔 - 68  文章 - 0 评论 - 0 阅读 - 15101
< 2025年4月 >
30 31 1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 1 2 3
4 5 6 7 8 9 10

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

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又不能用

 

posted on   xxyyjj  阅读(169)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示