SQL2005 高效分页sql语句

前端之家收集整理的这篇文章主要介绍了SQL2005 高效分页sql语句前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

1、
<div class="codetitle"><a style="CURSOR: pointer" data="34283" class="copybut" id="copybut34283" onclick="doCopy('code34283')"> 代码如下:

<div class="codebody" id="code34283">
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、
<div class="codetitle"><a style="CURSOR: pointer" data="25997" class="copybut" id="copybut25997" onclick="doCopy('code25997')"> 代码如下:
<div class="codebody" id="code25997">
select
from
( select ROW_NUMBER() OVER(order by id) as RowNum,username
from Guest where username = 'user'
) as T
where RowNum between 31 and 60

3、
<div class="codetitle"><a style="CURSOR: pointer" data="3970" class="copybut" id="copybut3970" onclick="doCopy('code3970')"> 代码如下:
<div class="codebody" id="code3970">
with T as
(select ROW_NUMBER() OVER(order by id) as RowNum,username
from Guest where username = 'user'
)
select * from T
where RowNum between 31 and 60

原文链接:https://www.f2er.com/mssql/66384.html
高效分页

猜你在找的MsSQL相关文章