日期:2014-05-17 浏览次数:20611 次
select *
from
(select *,rn=ROW_NUMBER() OVER(ORDER BY hits) from tb)
where rn between 2 and 10
create table zd
(id int, name varchar(5), hits int)
insert into zd
select 1, 'a', 110 union all
select 2, 'b', 60 union all
select 3, 'c', 200 union all
select 4, 'd', 15 union all
select 5, 'e', 80
select identity(int,1,1) 'rn', id,name,hits
into #t
from zd
order by hits desc
select rn-1 'rn',name,hits
from #t
where rn between 2 and 10
/*
rn name hits
----------- ----- -----------
1 a 110
2 e 80
3 b 60
4 d 15
(4 row(s) affected)
*/