min_n_by()
Track the smallest values and associated data in a set of values
Since 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
Section titled “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
Section titled “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 |