---
title: max_n() | Tiger Data Docs
description: Find the largest values in a set of data
---

Since [1.16.0](https://github.com/timescale/timescaledb-toolkit/releases/tag/1.16.0)

Construct an aggregate which will keep track of the largest values passed through it.

## Arguments

The syntax is:

```
max_n(
    value BIGINT | DOUBLE PRECISION | TIMESTAMPTZ,
    capacity BIGINT
) MaxN
```

| Name       | Type                                      | Default | Required | Description                          |
| ---------- | ----------------------------------------- | ------- | -------- | ------------------------------------ |
| `value`    | BIGINT \| DOUBLE PRECISION \| TIMESTAMPTZ | -       | ✔        | The values passed into the aggregate |
| `capacity` | BIGINT                                    | -       | ✔        | The number of values to retain.      |

## Returns

| Column | Type | Description                                                                                                                |
| ------ | ---- | -------------------------------------------------------------------------------------------------------------------------- |
| max\_n | MaxN | The compiled aggregate. Note that the exact type will be `MaxInts`, `MaxFloats`, or `MaxTimes` depending on the input type |
