Monday, May 14, 2012

Oracle select N latest entries

select * from (select * from monitor.at_process_log order by log_id desc) 
where ROWNUM <=10;
To accomplish the equivalent to MySql:
select * from sometable order by name limit 20,10
AskTom proposes:
select * from (select a.*, ROWNUM rnum from 
(select * from monitor.at_process_log order by log_id desc) a where rownum <= 20)
 where rnum >= 10;