分页问题的练习
use 最终的练习
select * from MyStudents
select * from
(select *, ROW_NUMBER() over(order by FId) as rowIndex
from MyStudents)as tb1
where tb1.rowIndex between(5*2+1)and 5*3
create proc usp_MyStudents_GetDateByPageIndex
@pageSize int=10, --要有一个(表示的是这一页有多少条数据,给了其一个默认值,这个默认值为10,表示的就是一次查询能显示10条记录)这一页有多少条的pageSize的参数,设其默认值为10
@pageIndex int --表示的是第几页
as
begin
select * from
(select *, ROW_NUMBER() over(order by FId) as rowIndex
from MyStudents)as tb1
where tb1.rowIndex between(@pageSize*(@pageIndex-1)+1)and @pageSize*@pageIndex
end
exec usp_MyStudents_GetDateByPageIndex 5,3