08/06/2012

[SQL] Oracle LIMIT clause

To limit the number of rows returned by a query, in standard SQL you would:

SELECT *
FROM table
WHERE [conditions]
LIMIT number

In Oracle you just add ROWNUM to the WHERE clause like:

SELECT *
FROM table
WHERE [conditions] AND ROWNUM=1

To have the equivalent of SQL "LIMIT 1"

No comments:

Post a Comment

With great power comes great responsibility