LIMIT / FETCH

constructsupportedQueries & DML

docs.snowflake.com ↗

Constrains the maximum number of rows returned by a statement or subquery. Both LIMIT (PostgreSQL syntax) and FETCH (ANSI syntax) are supported, and produce the same result.

Syntax

supportedpartialnot supportednot scored

SELECT ...
FROM ...
[ ORDER BY ... ]
LIMIT <count> [ OFFSET <start> ]
[ ... ]
SELECT ...
FROM ...
[ ORDER BY ... ]
[ OFFSET <start> ] [ { ROW | ROWS } ] FETCH [ { FIRST | NEXT } ] <count> [ { ROW | ROWS } ] [ ONLY ]
[ ... ]

Parameters

NameRequiredDescription
countThe number of rows returned. Must be a non-negative integer constant. The values NULL, empty string (''), and $$$$ are also accepted and are treated as “unlimited”; this is useful primarily for connectors and drivers (such as the JDBC driver) if they receive an incomplete parameter list when dynamically binding parameters to a statement.
OFFSET startThe row number after which the limited/fetched rows are returned. Must be a non-negative integer constant. If OFFSET is omitted, the output starts from the first row in the result set. The values NULL, empty string ('') and $$$$ are also accepted and are treated as 0 (i.e. do not skip any rows); this is useful primarily for connectors and drivers (such as the JDBC driver) if they receive an incomplete parameter list when dynamically binding parameters to a statement.
ONLYOptional keyword that does not affect the output. It is used for emphasis to the human reader.

Usage notes

Parameters

count: The number of rows returned. Must be a non-negative integer constant. The values NULL, empty string (''), and $$$$ are also accepted and are treated as “unlimited”; this is useful primarily for connectors and drivers (such as the JDBC driver) if they receive an incomplete parameter list when dynamically binding parameters to a statement. OFFSET start: The row number after which the limited/fetched rows are returned. Must be a non-negative integer constant. If OFFSET is omitted, the output starts from the first row in the result set. The values NULL, empty string ('') and $$$$ are also accepted and are treated as 0 (i.e. do not skip any rows); this is useful primarily for connectors and drivers (such as the JDBC driver) if they receive an incomplete parameter list when dynamically binding parameters to a statement. ONLY: Optional keyword that does not affect the output. It is used for emphasis to the human reader.

See also

Referenced by