OFFSET skips a specified number of rows in a result set before returning the remaining rows or the rows requested by a row-limiting clause.
OFFSET is useful for pagination and retrieving different sections of a large result set.
Skip the first 20 employees and return the next 10.
SELECT
EmployeeID,
EmployeeName,
Salary
FROM Employees
ORDER BY EmployeeID
OFFSET 20 ROWS
FETCH NEXT 10 ROWS ONLY;
OFFSET is commonly used in application pagination, report pages, and large-result navigation.
- OFFSET skips rows.
- It is commonly combined with FETCH.
- ORDER BY should be used for predictable pagination.
- OFFSET is useful for paginated results.
- Large offsets can have performance implications.
What does OFFSET do?
OFFSET skips a specified number of rows before returning the requested result.
Why is ORDER BY important with OFFSET?
ORDER BY provides a predictable row order so pagination remains consistent.