1-- Oracle <= 11g
2SELECT * FROM ( SELECT * FROM emp ORDER BY sal DESC ) WHERE ROWNUM <= 5;
3
4-- Oracle 12c +
5SELECT * FROM emp ORDER BY sal DESC FETCH FIRST 5 ROWS ONLY;
1SELECT *
2FROM sometable
3ORDER BY name
4OFFSET 20 ROWS FETCH NEXT 10 ROWS ONLY;
1syntax -> SELECT column_name(s)
2FROM table_name
3WHERE ROWNUM <= number
4////example///
5SELECT *
6FROM Persons
7WHERE ROWNUM <=5
1SELECT ROWNUM, a.*
2FROM (SELECT customers.*
3 FROM customers
4 WHERE customer_id > 4500
5 ORDER BY last_name) a;