sql2000 sql2005分页写法

sql2000分页写法,第二个第五页, 

select top 5 * from CustomerBusinessLicence where licenceid not in

(select top 5 licenceid from CustomerBusinessLicence order by licenceid desc)
 order by licenceid desc

如果是第一个第五页就是 

select top 5 licenceid from CustomerBusinessLicence order by licenceid desc 

 

sql2005里面有了row_number函数,那我们就用这个函数了

select * from (

select row_number() over(order by CreateTime  desc) as  rowNumber,*  

from  CustomerBusinessLicence

) A

where A.rownumber between 1 and 10 

posted @ 2010-08-30 21:14  艾伦  阅读(417)  评论(0编辑  收藏  举报