select * from
(select t.*,rownum row_num from mytable t order by t.id) b
where b.row_num between 1 and 10
结果发现由于该语句会先生成rownum 后执行order by 子句,因而排序结果根本不对,后来在GOOGLE上搜,原来多套一层select 就能很好的解决该问题,特此记录,语句如下:
select * from
(select a.*,rownum row_num from
(select * from mytable t order by t.id desc) a
) b where b.row_num between 1 and 10
验证过程如下:
select create_time from
(select t.*, rownum as rn from tablename t order by t.create_time desc )
where rn between 1 and 5
select create_time from
(select a.*,rownum row_num from
(select * from tablename t order by t.create_time desc) a
) b where b.row_num between 1 and 5