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
原理,根據(jù)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)