sqlserver 分页查询

DECLARE @pagesize INT= 10; --每页10条
DECLARE @page INT = 1; --第几页

SET STATISTICS TIME ON;
SELECT  *
FROM    ( SELECT    ROW_NUMBER() OVER ( ORDER BY id ASC ) AS rownumber ,
                    *
          FROM      AppNewsBackStage
        ) temp_row
WHERE   n_appId = 2
        AND rownumber BETWEEN ( @page - 1 ) * @pagesize + 1
                      AND     @page * @pagesize

 

posted @ 2019-07-01 18:08  _小马哥  阅读(182)  评论(0编辑  收藏  举报