declare @pageIndex int -- 第几页
declare @pageSize int  -- 每页包含的记录数

set @pageIndex=2
set @pageSize=50
--这里注意一下,不能直接把变量放在这里,要用select
select top (select @pageSize) *  
from 
(
SELECT ROW_NUMBER() over(order by 学号) as rownumber, GHO总表.学号, GHO总表.姓名, 手机号码 FROM [GHO总表],A1基本信息表   
where x01 = 学号  and 年级='2014' and 专业=  '法学'  and 库存类型及原因='正常在库' 
) temprows
-- temprows 是临时行,不能删除;否则语法错误
where rownumber>(@pageIndex-1)*@pageSize;

其实这个问题已经困扰我很多年了!!!!!

 

posted on 2019-08-25 18:21  qqhfeng16  阅读(721)  评论(0编辑  收藏  举报