按指定字段排序、分页
--取第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