zoukankan      html  css  js  c++  java
  • SQL分页查询语句


    ----方法一----------------------------------------------------------------
    select * from (select *, ROW_NUMBER() OVER (ORDER BY DeptName) as rownum from #tt) as tmpTable where rownum > ((@currpageno - 1) * @intPageSize) and rownum <= (((@currpageno - 1) * @intPageSize) + @intPageSize)

    ----方法二----------------------------------------------------------------
    select top (@intPageSize) * from #tt where DeptName not in( select top ((@currpageno-1)*@intPageSize) DeptName  from #tt)

    ----方法三----------------------------------------------------------------

    declare @no_show_recordcount int
    select @no_show_recordcount = @show_recordcount - (@currpageno - 1) * @intPageSize

    set @sql = 'select top  '+convert(varchar, @intPageSize) +'  * from ( select top '+convert(varchar,@no_show_recordcount)+' *  from #tt order by UserName desc ) a order by a.UserName asc'

  • 相关阅读:
    第 9 章
    第 8 章
    第 7 章
    第 6 章
    第 5 章
    第 4 章
    跳舞链解数独
    minic 类型声明与变量定义句型处理
    minic 动作句型处理
    minic 符号表
  • 原文地址:https://www.cnblogs.com/xytmj/p/xytmj_SQL_PageNum.html
Copyright © 2011-2022 走看看