--ID连续
select * from CardInfo where ID>=10 and ID<=20
--查询11-20条数据 查出来结果是12-21
--ID不连续
--外层查询没有对表A查询,效率大有提高
select top 10 * from (select top 20 * from CardInfo order by ID)a
order by ID desc
--两次对表A查询效率较低
select top 10 * from CardInfo where ID not in (select top 10 ID from CardInfo)
--ROW_NUMBER()函数效率更高,sqlserver2005以及以上版本中才可以使用
select * from (select *,row_number() over (order by id) as a from CardInfo) as temp
where a between 11 and 20