Select top PageCount * From [tb_code] Where id>=(select min(id) from (select top (Page-1)*PageCount+1 id from [tb_code] order by id desc) as t) order by id desc
原理,根据ID计算出(Page-1)页的最小值,然后用TOP关键字及可解决问题。
2.SELECT TOP 10 id,username From [tb_code] where id not in ( SELECT TOP 20000 id FROM tb_code ORDER BY username)