select * from sc where (select count(*) from sc sc2 where sc2.score>sc.score and sc2.class=sc.class)<=2 order by sc.class,sc.score desc;
select * from sc having (select count(*) from sc t1 where t1.class=sc.class and t1.score>=sc.score)<=3;
select * from sc where exists (select count(*) from sc sc2 where sc2.score>sc.score and sc2.class=sc.class having count(*)<=2) order by sc.class,sc.score desc;
select t1.sid,t1.class,t1.score from sc t1,sc t2 where t1.class=t2.class and t2.score>=t1.score group by t1.sid,t1.class,t1.score having count(t2.sid)<=3 order by t1.class,t1.score desc;

相关文章:

  • 2021-07-31
  • 2022-02-08
  • 2021-10-12
  • 2022-01-01
  • 2021-09-08
  • 2021-12-06
猜你喜欢
  • 2022-01-01
  • 2021-09-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2023-03-21
相关资源
相似解决方案