declare @pageSize int=15
declare @FootPage int=(select COUNT(*) from [职员基本信息表])/15
exec select top (@pageSize) * from [职员基本信息表] where ID not in (select top (@pageSize*@FootPage) * from [职员基本信息表])pageSize是一页显示的信息数,每页显示15条信息
FootPage是尾页我想查询尾页的信息

解决方案 »

  1.   


    --你@pageSize*@FootPage不就是所有记录了吗?再not in还能有记录吗?
    exec select top (@pageSize) * from [职员基本信息表] 
    where ID not in (select top ((@pageSize-1)*@FootPage) * from [职员基本信息表])
      

  2.   

    查询尾页的信息declare @iPageSize int
    SET @iPageSize =20
    declare @iCurrentPage int
    SET @iCurrentPage =1declare @iTotalPageCount int
    select @iTotalPageCount= count(1)/@iPageSize FROM tblDiary
    set @iCurrentPage=@iTotalPageCountdeclare @sSql varchar(4000) 
    SET @sSql=
    'Select Top ' + convert(varchar,@iPageSize) + ' * from tblDiary where DiaryID 
    not in
    (
    select top ' + convert(varchar,@iPageSize  * @iCurrentPage) + ' DiaryID from tblDiary order by DiaryID asc
    ) order by DiaryID asc'--PRINT @sSqlexec(@sSql)
      

  3.   

    建议楼主:
    1. 最好查下分页相关的知识,如何实现
    2. 你的SQL语句的语法都不对哦  IN 和 Exists 的使用再熟悉下吧