欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

分页查询(用row_number()和开窗函数over()更方便)

程序员文章站 2024-01-01 14:14:16
...

分页查询(用row_number()和开窗函数over()更方便) 查询MyStudents表中第8页中的数据(每页3条记录) www.2cto.com --(1) select * from ( select *, ROW_NUMBER()over(order by FId asc) as Rnumber from MyStudents ) as Tbl3 where Rnumber between (3*7


分页查询(用row_number()和开窗函数over()更方便)

查询MyStudents表中第8页中的数据(每页3条记录)

www.2cto.com

--(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

上一篇:

下一篇: