VeloDB Cloud
SQL Reference
SQL Functions
Aggregate Functions
MIN_BY

MIN_BY

Description

The MIN_BY function is used to return the corresponding associated value based on the minimum value of the specified column.

Syntax

MIN_BY(<expr1>, <expr2>)

Parameters

ParametersDescription
<expr1>The expression used to specify the corresponding association.
<expr2>The expression used to specify the minimum value for statistics.

Return Value

Returns the same data type as the input expression .

Example

select * from tbl;
+------+------+------+------+
| k1   | k2   | k3   | k4   |
+------+------+------+------+
|    0 | 3    | 2    |  100 |
|    1 | 2    | 3    |    4 |
|    4 | 3    | 2    |    1 |
|    3 | 4    | 2    |    1 |
+------+------+------+------+
select min_by(k1, k4) from tbl;
+--------------------+
| min_by(`k1`, `k4`) |
+--------------------+
|                  4 |
+--------------------+