sql 分页

 

按指定字段排序、分页

--取第5页的30条数据
DECLARE @Page INT = 5
DECLARE @PageSize INT = 30
SELECT ep_survivalstatus,
       ep_CardNo
FROM dbo.ep_CardBase
ORDER BY CASE
             WHEN ep_survivalstatus = 778170000 THEN
                 0
             WHEN ep_survivalstatus = 778170001 THEN
                 1
             WHEN ep_survivalstatus = 778170002 THEN
                 2
             WHEN ep_survivalstatus = 77817003 THEN
                 3
         END OFFSET (@Page - 1) * @PageSize ROWS FETCH NEXT @PageSize ROWS ONLY

 

--取第5页的30条数据
DECLARE @Page INT = 5
DECLARE @PageSize INT = 30
SELECT ep_survivalstatus,
       ep_CardNo
FROM dbo.ep_CardBase
ORDER BY ep_CardNo OFFSET (@Page - 1) * @PageSize ROWS FETCH NEXT @PageSize ROWS ONLY

 

sql 分页

上一篇:Mysql-DQL、DML、DDL、DCL的概念与区别


下一篇:使用Oracle SQL Developer工具完成Mariadb数据库迁移到Oracle数据库