top_n
Returns the top N rows based on a specified column.
Syntax
top_n(<table>, <limit>)
| Parameter | Type | Description |
|---|---|---|
| table | Table | The table to operate on. |
| limit | Integer | The maximum number of rows to return. |
Return values
Table
Usage
Returns the top 10 orders by total price in descending order.
top_n(orders, 10, orders.total_price desc)