SQL Server 2005 存儲過程分頁

create table t1
(
 id int,
 s1 int
)

Declare @i int
set @i=1
while(@i<200000)
begin
 insert into t1 values(@i+1,@i)
 set @i=@i+1
end

select t.id,t.s1,t.pos from
(
select *,row_number() over (order by s1 desc) as pos from t1
) as t
where t.pos >= 1 and t.pos <= 10

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章