Select the first 150 rows, then the next 150 and so on?

sabisabi picture sabisabi · Mar 9, 2012 · Viewed 38.8k times · Source

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...

Answer

xbonez picture xbonez · Mar 9, 2012

LIMIT 150 or LIMIT 0,150 : first 150 rows

LIMIT 150,150 : next 150 rows

LIMIT 300,150 : next 150 rows

and so on