How can I select in oracle sql in a Table the first x rows, then the next x and so on? I know I could use TOP/LIMIT, then I get the first x
select a from b limit 150 => get the first 150 rows.
Edit: Why? I would like to copy the first 150 outputs into a file, then the next 150 into another file and so on…
In Oracle you have the nice
rownum: it is a pseudo column. It numbers the records in a result set. The first record that meets the where criteria in a select statement is givenrownum=1, and every subsequent record meeting that same criteria increasesrownum.(thanks to @Mark Bannister)
If you embed the ORDER BY clause in a subquery and place the ROWNUM condition in the top-level query, then you can force the ROWNUM condition to be applied after the ordering of the rows.