sqlserver 分页

select top 10 numComImg.* from
( select row_number() over(order by id asc) as rownumber,* from (select * FROM [TCCLine].[dbo].[CLine_CommonImage]) as comImg)
as numComImg where rownumber>40
 
 
select top 10 * --10 为页大小
from [TCCLine].[dbo].[CLine_CommonImage]
where id not in
(
--40是这么计算出来的:10*(5-1)
-- 页大小*(查询第几页-1)
select top 40 id from [TCCLine].[dbo].[CLine_CommonImage] order by id
)
order by id
 
第一种效率高
原文地址:https://www.cnblogs.com/sddychj/p/6762728.html