# TOP

The TOP function collects the top values for a specified field, including repeated values.

## Syntax

`TOP(field, limit, order, outputField)`

### Parameters

#### field

The field to collect the top values for.

#### limit

The maximum number of values to collect.

#### order

The order to calculate the top values. Either `asc` or `desc`. If omitted, defaults to `asc`.

#### outputField

Optional. If present, this field will be the output of the TOP call instead of `field`.

## Examples

Retrieves the top 3 highest salary values from the employees index in descending order and also calculates the maximum salary.

```esql
FROM employees
| STATS top_salaries = TOP(salary, 3, "desc"), top_salary = MAX(salary)
```