sql选取第n高的选项

select * from sc where score=(select max(score) from sc where score<>(select max(score) from sc))

不灵活

 

select *
from 
(
select row_number() over (order by score desc) as idx, * from sc 
) as tmptable
where idx <>1

表太大有性能问题

 

select top 1 * from sc where score in (select top 5 score from sc order by score desc) order by score asc

目前考虑用的

posted on 2010-02-18 11:05  无法显示此网页  阅读(245)  评论(0编辑  收藏  举报

导航