# top

Shows the most common values.

```tql
top x:field
```

## Description

Shows the most common values for a given field. For each value, a new event containing its count will be produced. In general, `top x` is equivalent to:

```tql
summarize x, count=count()
sort -count
```

This operator is the dual to [`rare`](https://preview.docs.tenzir.com/375/375/reference/operators/rare.md).

Potentially High Memory Usage

Use caution when applying this operator to large inputs. It currently buffers all data in memory. Out-of-core processing is on our roadmap.

### `x: field`

The field to find the most common values for.

## Examples

### Find the most common values

```tql
from {x: "B"}, {x: "A"}, {x: "A"}, {x: "B"}, {x: "A"}, {x: "D"}, {x: "C"}, {x: "C"}
top x
```

```tql
{x: "A", count: 3}
{x: "B", count: 2}
{x: "C", count: 2}
{x: "D", count: 1}
```

### Show the 5 top-most values

```tql
top id.orig_h
head 5
```

## See Also

* [`rare`](https://preview.docs.tenzir.com/375/375/reference/operators/rare.md)
* [`sort`](https://preview.docs.tenzir.com/375/375/reference/operators/sort.md)
* [`summarize`](https://preview.docs.tenzir.com/375/375/reference/operators/summarize.md)
* [Aggregate event streams](https://preview.docs.tenzir.com/375/375/guides/analytics/aggregate-event-streams.md)
* [Plot data with charts](https://preview.docs.tenzir.com/375/375/tutorials/plot-data-with-charts.md)