TOP <N>
constructsupportedQueries & DMLConstrains the maximum number of rows returned by a statement or subquery.
Syntax
SELECT
[ TOP <n> ]
...
FROM ...
[ ORDER BY ... ]
[ ... ]
Parameters
| Name | Required | Description |
|---|---|---|
n | The maximum number of rows to return in the result set. |
Usage notes
- An ORDER BY clause is not required; however, without an ORDER BY clause, the results are non-deterministic because results within a result set are not necessarily in any particular order. To control the results returned, use an ORDER BY clause.
- When TOP <n> and ORDER BY are at different nesting levels in a query, results can be unpredictable. For details and examples, see the LIMIT / FETCH usage notes.
- n must be a non-negative integer constant.
- TOP n and LIMIT count are equivalent.
Parameters
n: The maximum number of rows to return in the result set.