各種データベースページングSQL


1、Oracle
select * from (select e.*, rownum rn from (select * from test order by id) e where rownum <= 10) where rn >= 1;

 
2、MySql
select * from test order by id desc limit 1,10;

 
3、SQL Server
select top 10 * from test where id not in (select top 1 id from test order by id desc)order by id desc;

 
4、DB2
select * from (select e.*,rownumber() over(order by id asc) as rowid from test e) as t where t.rowid>=1 and t.rowid<10