JDBC escape syntax for limit/offset clauses

The LIMIT escape clause can occur in a query at the point where an OFFSET/FETCH FIRST clause can appear. See The result offset and fetch first clauses for more information.

Syntax

{ LIMIT rowCount [ OFFSET startRow ] }

The rowCount is a non-negative integer that specifies the number of rows to return. If rowCount is 0, all rows from startRow forward are returned.

The startRow is a non-negative number that specifies the number of rows to skip before returning results.

Equivalent to

OFFSET startRow FETCH NEXT rowCount ROWS ONLY

Examples

-- return the first two rows of sorted table t
SELECT * FROM t
ORDER BY a
{ LIMIT 2 }
-- return two rows of sorted table t, starting with the eleventh row
SELECT * FROM t
ORDER BY a
{ LIMIT 2 OFFSET 10 }
Related reference
JDBC escape keyword for call statements
JDBC escape syntax for LIKE clauses
JDBC escape syntax for fn keyword
JDBC escape syntax for outer joins
JDBC escape syntax for time formats
JDBC escape syntax for date formats
JDBC escape syntax for timestamp formats