How to Limit Rows in Oracle
Last updated August 25, 2026 · By the SaturnSQL team
Use FETCH FIRST n ROWS ONLY (12c+) to cap a result set, and OFFSET ... FETCH NEXT for paging. Older Oracle code limits rows with ROWNUM instead.
SELECT employee_id, last_name, salary
FROM employees
ORDER BY salary DESC
FETCH FIRST 10 ROWS ONLY;Paging with OFFSET
OFFSET skips rows before FETCH counts them, which is the standard way to build page 2, page 3, and so on.
SELECT order_id, customer_id, order_total
FROM orders
ORDER BY order_date DESC
OFFSET 20 ROWS FETCH NEXT 10 ROWS ONLY;Including ties
WITH TIES returns extra rows that tie the last value in the ORDER BY, so the count can exceed n. It requires an ORDER BY, unlike plain FETCH FIRST.
SELECT employee_id, salary
FROM employees
ORDER BY salary DESC
FETCH FIRST 5 ROWS WITH TIES;FETCH FIRST needs Oracle 12c or later. Code written for 11g and earlier limits rows with ROWNUM instead, which behaves very differently since it is assigned before ORDER BY runs.
Run this in SaturnSQL
SaturnSQL is a browser-based SQL editor for teams: shared query library, schema-aware autocomplete, and scheduled exports to Google Sheets and Slack.
Try it free