# Top rows
> Supported in: Batch, Faster
Picks the top rows in each sorted partition.
**Transform categories**: Aggregate
## Declared arguments
* **Dataset:** Input dataset.
*Table*
* **Partition by columns:** Set of columns to determine each partition from.
*Set\>*
* **Sort specification:** Specification for how to sort each partition. At least one specification is required.
*List\, Enum\>>*
* *optional* **Number of rows:** Number of rows to select, defaults to 1.
*Literal\*
## Examples
### Example 1: Base case
**Argument values:**
* **Dataset:** ri.foundry.main.dataset.a
* **Partition by columns:** {`airline`}
* **Sort specification:** \[(`airport`, `DESCENDING`), (`miles`, `ASCENDING`)]
* **Number of rows:** *null*
**Input:**
| airline | airport | miles |
| ----- | ----- | ----- |
| foundry airways | JFK | 1002345 |
| foundry airways | LHR | 2221324 |
| new air | SFO | 21356673 |
| new air | JFK | 12323456 |
| foundry airways | LHR | 12542352 |
| new air | JFK | 12232355 |
**Output:**
| airline | airport | miles |
| ----- | ----- | ----- |
| foundry airways | LHR | 2221324 |
| new air | SFO | 21356673 |
***
### Example 2: Base case
**Argument values:**
* **Dataset:** ri.foundry.main.dataset.a
* **Partition by columns:** {}
* **Sort specification:** \[(`airline`, `DESCENDING`), (`airport`, `DESCENDING`), (`miles`, `ASCENDING`)]
* **Number of rows:** 2
**Input:**
| airline | airport | miles |
| ----- | ----- | ----- |
| foundry airways | JFK | 1002345 |
| foundry airways | LHR | 2221324 |
| new air | SFO | 21356673 |
| new air | JFK | 12323456 |
| foundry airways | LHR | 12542352 |
| new air | JFK | 12232355 |
**Output:**
| airline | airport | miles |
| ----- | ----- | ----- |
| new air | SFO | 21356673 |
| new air | JFK | 12232355 |
***
### Example 3: Base case
**Argument values:**
* **Dataset:** ri.foundry.main.dataset.a
* **Partition by columns:** {}
* **Sort specification:** \[]
* **Number of rows:** 1
**Input:**
| airline | airport | miles |
| ----- | ----- | ----- |
| foundry airways | JFK | 1002345 |
| foundry airways | LHR | 2221324 |
| new air | SFO | 21356673 |
| new air | JFK | 12323456 |
| foundry airways | LHR | 12542352 |
| new air | JFK | 12232355 |
**Output:**
| airline | airport | miles |
| ----- | ----- | ----- |
| foundry airways | JFK | 1002345 |
***
### Example 4: Base case
**Argument values:**
* **Dataset:** ri.foundry.main.dataset.a
* **Partition by columns:** {}
* **Sort specification:** \[(`value`, `ASCENDING`)]
* **Number of rows:** 0
**Input:**
| value |
| ----- |
| 1 |
| 2 |
**Output:**
| value |
| ----- |
***