2020-06-18 08:24:31 +00:00
---
toc_priority: 105
---
# argMin {#agg-function-argmin}
2020-11-24 11:25:45 +00:00
Syntax: `argMin(arg, val)` or `argMin(tuple(arg, val))`
2020-06-18 08:24:31 +00:00
Calculates the `arg` value for a minimal `val` value. If there are several different values of `arg` for minimal values of `val` , the first of these values encountered is output.
2020-11-24 11:25:45 +00:00
Tuple version of this function will return the tuple with the minimal `val` value. It is convinient for use with `SimpleAggregateFunction` .
2020-06-18 08:24:31 +00:00
**Example:**
``` text
┌─user─────┬─salary─┐
│ director │ 5000 │
│ manager │ 3000 │
│ worker │ 1000 │
└──────────┴────────┘
```
``` sql
2020-11-24 11:25:45 +00:00
SELECT argMin(user, salary), argMin(tuple(user, salary)) FROM salary
2020-06-18 08:24:31 +00:00
```
``` text
2020-11-24 11:25:45 +00:00
┌─argMin(user, salary)─┬─argMin(tuple(user, salary))─┐
│ worker │ ('worker',1000) │
└──────────────────────┴─────────────────────────────┘
2020-06-18 08:24:31 +00:00
```