wangyonglong
--方法一:
select a.id,a.SName,a.ClsNo,a.Score
    from Table1 a left join Table1 b on a.ClsNo=b.ClsNo and a.Score<b.Score
        group by a.id,a.SName,a.ClsNo,a.Score
        having count(b.id)<2
    order by a.ClsNo,a.Score desc

--方法二:
select *
    from Table1 a
        where 2>(select count(*) from Table1 where ClsNo=a.ClsNo  and Score>a.Score)
    order by a.ClsNo,a.Score desc

--方法三:
select *
    from Table1 a
        where id in (select id from Table1 where ClsNo=a.ClsNo order by Score desc limit 2)
    order by a.ClsNo,a.Score desc

 

分类:

技术点:

相关文章:

  • 2022-01-01
  • 2022-12-23
  • 2021-09-16
  • 2022-12-23
  • 2021-08-09
  • 2022-12-23
  • 2021-12-02
猜你喜欢
  • 2021-08-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-25
  • 2022-12-23
相关资源
相似解决方案