SQL分页查询多种写法
作者:C/S框架网  发布日期:2018-07-22 20:07:16
  SQL分页查询多种写法



WITH T AS
(
SELECT *,ROW_NUMBER() OVER(ORDER BY CreateTime) AS rowNum FROM 资料表
)
SELECT * FROM T WHERE rowNum BETWEEN 11 AND 20




SELECT *,ROW_NUMBER() OVER(ORDER BY Code) AS rowNum INTO #a FROM  资料表

SELECT * FROM #a WHERE rowNum BETWEEN 11 AND 20




SELECT * FROM (
                SELECT  *, ROW_NUMBER() OVER (ORDER BY CreateTime DESC) AS 'SN'
                FROM  资料表 
WHERE 1=1) temp WHERE SN BETWEEN 1 AND 10



上一篇 下一篇