Posts Oracle select n rows
Post
Cancel

Oracle select n rows

  • Oracle 11 or before
1
2
3

SELECT * FROM (SELECT COLUMN1, COLUMN2 FROM TABLE_NAME ORDER BY COLUMN1 desc) WHERE rownum =1;

  • Oracle 12 or above
1
2
3

SELECT COLUMN1, COLUMN2 FROM TABLE_NAME ORDER BY COLUMN1 desc fetch first 1 rows only;

Oracle Blog

This post is licensed under CC BY 4.0 by the author.