MIN_BY

description

Syntax

MIN_BY(expr1, expr2)

Returns the value of an expr1 associated with the minimum value of expr2 in a group.

example

1. MySQL > select * from tbl;
2. +------+------+------+------+
3. | k1   | k2   | k3   | k4   |
4. +------+------+------+------+
5. |    0 | 3    | 2    |  100 |
6. |    1 | 2    | 3    |    4 |
7. |    4 | 3    | 2    |    1 |
8. |    3 | 4    | 2    |    1 |
9. +------+------+------+------+

11. MySQL > select min_by(k1, k4) from tbl;
12. +--------------------+
13. | min_by(`k1`, `k4`) |
14. +--------------------+
15. |                  4 |
16. +--------------------+

keywords

MIN_BY