Returns the first N records sorted by the specified columns.
T | top 5 by Name desc nulls last
| top NumberOfRows
by Expression [
nulls first |
- NumberOfRows: The number of rows of T to return. You can specify any numeric expression.
- Expression: A scalar expression by which to sort. The type of the values must be numeric, date, time or string.
desc(the default) may appear to control whether selection is actually from the "bottom" or "top" of the range.
nulls first(the default for
nulls last(the default for
descorder) may appear to control whether null values will be at the beginning or the end of the range.
top 5 by name is superficially equivalent to
sort by name | take 5. However, it runs faster and always returns sorted results, whereas
take makes no such guarantee.
top-nested allows to produce hierarchical top results.