VeloDB Cloud
SQL Manual
Functions
aggregate-functions
MIN_BY

MIN_BY

Description

Syntax:

MIN_BY(expr1, expr2)

This function returns the value in expr1 that is associated with the minimum value in expr2.

Example

MySQL > select * from tbl;
+------+------+------+------+
| k1   | k2   | k3   | k4   |
+------+------+------+------+
|    0 | 3    | 2    |  100 |
|    1 | 2    | 3    |    4 |
|    4 | 3    | 2    |    1 |
|    3 | 4    | 2    |    1 |
+------+------+------+------+

MySQL > select min_by(k1, k4) from tbl;
+--------------------+
| min_by(`k1`, `k4`) |
+--------------------+
|                  4 |
+--------------------+ 

Keywords

MIN_BY