SQL2005 高效分页sql语句
程序员文章站
2022-05-23 18:18:00
1、 复制代码 代码如下: select top 10 * from ( select top (@page * 10) row_number() over (order...
1、
select top 10 * from
( select top (@page * 10) row_number() over (order by id) as rownum, id, username
from guest where username = 'user'
) as t
where rownum > ((@page - 1) * 10)
2、
select * from
( select row_number() over(order by id) as rownum,id,username
from guest where username = 'user'
) as t
where rownum between 31 and 60
3、
with t as
(select row_number() over(order by id) as rownum,,id,username
from guest where username = 'user'
)
select * from t
where rownum between 31 and 60
复制代码 代码如下:
select top 10 * from
( select top (@page * 10) row_number() over (order by id) as rownum, id, username
from guest where username = 'user'
) as t
where rownum > ((@page - 1) * 10)
2、
复制代码 代码如下:
select * from
( select row_number() over(order by id) as rownum,id,username
from guest where username = 'user'
) as t
where rownum between 31 and 60
3、
复制代码 代码如下:
with t as
(select row_number() over(order by id) as rownum,,id,username
from guest where username = 'user'
)
select * from t
where rownum between 31 and 60