分页查询 (用row_number() 和开窗函数over()更方便)
2012-11-07 19:38
477 查看
查询MyStudents表中 第8页中的数据(每页3条记录)
--(1)
select * from
(
select *,
ROW_NUMBER()over(order by FId asc) as Rnumber
from MyStudents
)
as Tbl3
where Rnumber between (3*7+1) and 3*8
--(2)
select top 3 * from MyStudents
where FId not in
(select top (3*7) FId from MyStudents
order by FId )
order by FId
--(1)
select * from
(
select *,
ROW_NUMBER()over(order by FId asc) as Rnumber
from MyStudents
)
as Tbl3
where Rnumber between (3*7+1) and 3*8
--(2)
select top 3 * from MyStudents
where FId not in
(select top (3*7) FId from MyStudents
order by FId )
order by FId
相关文章推荐
- mysql、MS SQL关于分页的sql查询语句 limit 和row_number() OVER函数
- mysql、MS SQL关于分页的sql查询语句 limit 和row_number() OVER函数
- SQL关于分页的sql查询语句 limit 和row_number() OVER函数
- [转]SQLServer2005新的高效分页方法-row_number()over函数的使用
- 转:SQL Server 2005 的分页查询(ROW_NUMBER() OVER
- SQL Server 2005 的分页查询(ROW_NUMBER() OVER 语句)
- sql "ROW_NUMBER() OVER()"函数,编号,分组,分页
- MSSQL分页:查询前几页速度最快的ROW_NUMBER() OVER分页存贮过程
- row_number() over() 一句话概括,以及max()函数的一种查询分组中最大值的用法
- oracle 分析函数和开窗函数 ROW_NUMBER() OVER(PARTITION BY.....)
- row_number() over order by与利用rownum查询分页效率分析
- row_number()函数--查询第20条到第30条数据-分页查询
- SQL 分页查询-ROW_NUMBER() 函数
- SQLServer2005新的高效分页方法-row_number()over函数的使用
- sql 用ROW_NUMBER() over函数简单分页
- sqlserver_分页查询_row_number() over()
- SQL 分页支持查询 ROW_NUMBER() OVER (ORDER BY ReportID) AS RowNo
- 11-6数据库加强(子查询(独立子查询,相关子查询),分页显示,开窗函数 over(),join )
- sql开窗函数 row_number () over(order by id )
- DB2分页查询sql和ROW_NUMBER()函数