Getting n of m rows in a query – Oracle 9i and +

April 5, 2006 · Posted in oracle · Comment 

select *
from (
select a.*, rownum rnum
from ( YOUR_QUERY_GOES_HERE — including the order by ) a
where rownum <= MAX_ROWS
)
where rnum >= MIN_ROWS