`
liushengchao
  • 浏览: 11710 次
  • 性别: Icon_minigender_1
  • 来自: 莱芜
最近访客 更多访客>>
社区版块
存档分类
最新评论

SQL 的分页

SQL 
阅读更多
with temptbl as (          -----临时表名  
  SELECT ROW_NUMBER() OVER (ORDER BY id desc)AS Row, * from  表名   
  ...   
)   
SELECT * FROM temptbl where Row between @startIndex and @endIndex  



select top 每页显示的记录数 * from topic where id not in  
 (select top (当前的页数-1)×每页显示的记录数 id from topic order by id desc)   
 order by id desc
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics