日期:2014-05-18 浏览次数:20620 次
select top 15 * from ( select * from table where sid=1004 ) as M where id > (select max (id) from (select top (15 * (20 - 1)) id from ( select * from table where sid=1004 ) as M where order by id ) as T ) order by id
declare @pagesize int set @pagesize=15 --每页15条 declare @pageindex int set @pageindex=2 --第20页 ;with maco as ( select row_number() over (order by id) as num,* from [table] where sid=1004 ) select * from maco where num between (@pagesize*(@pageindex-1)+1) and @pageindex*@pagesize