---
title: min_n_by() | Tiger Data Docs
description: Track the smallest values and associated data in a set of values
---

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

Construct an aggregate that keeps track of the smallest values passed through it, as well as some associated data which is passed alongside the value.

## Arguments

The syntax is:

```
min_n_by(
    value BIGINT | DOUBLE PRECISION | TIMESTAMPTZ,
    data ANYELEMENT,
    capacity BIGINT
) MinNBy
```

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

## Returns

| Column     | Type   | Description                                                                                                                 |
| ---------- | ------ | --------------------------------------------------------------------------------------------------------------------------- |
| min\_n\_by | MinNBy | The compiled aggregate. Note that the exact type is `MinByInts`, `MinByFloats`, or `MinByTimes` depending on the input type |
