Skip to content

max_n()

Find the largest values in a set of data

Since 1.16.0

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

The syntax is:

max_n(
value BIGINT | DOUBLE PRECISION | TIMESTAMPTZ,
capacity BIGINT
) MaxN
NameTypeDefaultRequiredDescription
valueBIGINT | DOUBLE PRECISION | TIMESTAMPTZ-The values passed into the aggregate
capacityBIGINT-The number of values to retain.
ColumnTypeDescription
max_nMaxNThe compiled aggregate. Note that the exact type will be MaxInts, MaxFloats, or MaxTimes depending on the input type