不见不散

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

-- 单科最高分是谁
select * from topn where sco in (select max(sco) from topn group by clsno);
-- 单科最高分是谁
select * from topn a
where not exists (select * from topn where ClsNo=a.ClsNo and sco>a.Sco);
-- 单科前两名
select * from topn a where 2>(select count(*) from topn b where a.ClsNo=b.clsno and sco>a.Sco)
order by a.ClsNo ,a.Sco desc;

posted on 2018-11-23 16:06  不见不散789  阅读(227)  评论(0编辑  收藏  举报