OFFSET Clause

The OFFSET clause is used to specify a number N of initial query results that should be skipped (not returned to the application). N is computed by an expression that may be a single integer literal, or a single external variable, or any expression which is built from literals and external variables and returns a single non-negative integer.

Syntax

offset_clause ::= OFFSET add_expression

Semantics

Although it's possible to use offset without an order-by clause, it does not make much sense to do so. This is because without an order-by, results are returned in a random order, so the subset of results skipped will be different each time the query is run.

Example 6-21 OFFSET Clause

SELECT * FROM users 
WHERE age > 30 
ORDER BY age 
OFFSET 10;