Syntax
ARG_MAX([DISTINCT] minimize_col, return_col)
Purpose
The ARG_MIN function is used to find the row in a dataset that minimizes the target expression and returns the value of the specified column or the complete record corresponding to that row.
Where:
minimize_colis the column to be minimized.return_colis the column corresponding to the return value, which returns the value of this column in the row with the minimum value. If it isNULL, the row is ignored.
Examples
obclient> SELECT * FROM test;
+------+------+
| a | b |
+------+------+
| a | 1 |
| b | 2 |
| c | 2 |
| NULL | 3 |
| NULL | NULL |
| d | NULL |
+------+------+
6 rows in set (0.000 sec)
obclient> SELECT arg_min(a, b), min(b) FROM test;
+---------------+--------+
| arg_min(a, b) | min(b) |
+---------------+--------+
| a | 1 |
+---------------+--------+
1 row in set (0.006 sec)