limit
Limits the number of results that are returned. If you don’t set a limit, queries return
a maximum of 10,000 rows.
Syntax
result = limit rows number;
Usage
Use this statement only on data that has been ordered with the order statement. The results of a limit operation aren’t automatically ordered, and their order can change each time that statement is called.
You can use the limit statement with ungrouped data.
You can use the limit statement to limit grouped data by an aggregated value. For example, to find the top 10 regions by revenue: group by region, call sum(revenue) to aggregate the data, order by sum(revenue) in descending order, and limit the number of results to the first 10.
Example
This example limits the number of returned results to
10:
b = limit a 10;
The expression can’t contain any columns from the input. For example, this query is not
valid:
b = limit OrderDate 10;