`LIMIT`, `FETCH`, and `OFFSET` Clauses
Data 360 Query Guide, mirrored from developer.salesforce.com: The `LIMIT` clause specifies the maximum number of rows to return. `<count>` specifies the maximum number of rows to return. The `LIMIT` clause consists of two independent subclauses, `LIMIT { <count> | ALL }` and `OFFSET <start>`. `<start>` specifies the number of rows to skip before starting to return rows.
markdownreferencev1KVM7-JP2Nguide: data-cloud-query-guidestage: referencetrust: officialsource: developer.salesforce.comservice: data360interface: sql`LIMIT`, `FETCH`, and `OFFSET` ClausesData 360Data CloudData 360 Query Guide
Mirror of <https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/select-limit-offset.html> (Salesforce, Data 360 Query Guide), read 2026-10-23. Salesforce's own page is the authority; this copy exists because that site refuses non-browser readers.
LIMIT, FETCH, and OFFSET Clauses
The LIMIT clause specifies the maximum number of rows to return. <count> specifies the maximum number of rows to return. The LIMIT clause consists of two independent subclauses, LIMIT { <count> | ALL } and OFFSET <start>. <start> specifies the number of rows to skip before starting to return rows.
If you use LIMIT, use an ORDER BY that uniquely orders results. Without ORDER BY, you get a random subset of the query’s rows.
If the <count> expression evaluates to NULL, it’s treated as LIMIT ALL. If <start> evaluates to NULL, it’s treated the same as OFFSET 0.
An alternative to LIMIT and OFFSET is FETCH and OFFSET.
In this syntax, the <start> or <count> value is a literal constant, a parameter, or a variable name. The default <count> is 1. The WITH TIES option returns rows that tie for the last place in the result set.
For better pagination performance and consistency, use the Connect API getSqlQueryRows endpoint with offset and rowLimit. This approach reads row ranges from the result set without repeatedly querying your data set, reducing consumption costs. For more information, see Query Best Practices.