写分页用的SQL(备忘)

这里使用了SQL2005以上版本的内置函数 row_number()方法;

over里是根据什么进么排序;

rownum为子表的别名;

 where t.rownum >=11 and t.rownum <=20  以出十条记录;

select * from 
(
    
select Id,Name,row_number() over(order by id)as rownum
    
from category
    
where
    id 
> 30
)t
where t.rownum >=11 and t.rownum <=20
原文地址:https://www.cnblogs.com/zhuiyi/p/2045383.html