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 equivalent to the expression
sort by name | take 5 both from semantic and performance perspectives.
- Use top-nested operator to produce hierarchical (nested) top results.