2021-02-02 12:00:41 +00:00
|
|
|
---
|
2022-08-26 19:07:59 +00:00
|
|
|
slug: /zh/sql-reference/aggregate-functions/reference/argmin
|
2022-04-10 23:08:18 +00:00
|
|
|
sidebar_position: 105
|
2021-02-02 12:00:41 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
# argMin {#agg-function-argmin}
|
|
|
|
|
|
|
|
语法: `argMin(arg, val)` 或 `argMin(tuple(arg, val))`
|
|
|
|
|
2024-04-11 19:51:05 +00:00
|
|
|
计算 `val` 最小值对应的 `arg` 值。
|
2021-02-02 12:00:41 +00:00
|
|
|
|
|
|
|
**示例:**
|
|
|
|
|
2021-03-24 15:46:03 +00:00
|
|
|
输入表:
|
|
|
|
|
2021-02-02 12:00:41 +00:00
|
|
|
``` text
|
|
|
|
┌─user─────┬─salary─┐
|
|
|
|
│ director │ 5000 │
|
|
|
|
│ manager │ 3000 │
|
|
|
|
│ worker │ 1000 │
|
|
|
|
└──────────┴────────┘
|
|
|
|
```
|
|
|
|
|
2021-03-24 15:46:03 +00:00
|
|
|
查询:
|
|
|
|
|
2021-02-02 12:00:41 +00:00
|
|
|
``` sql
|
2021-10-19 16:14:14 +00:00
|
|
|
SELECT argMin(user, salary), argMin(tuple(user, salary), salary) FROM salary;
|
2021-02-02 12:00:41 +00:00
|
|
|
```
|
|
|
|
|
2021-03-24 15:46:03 +00:00
|
|
|
结果:
|
|
|
|
|
2021-02-02 12:00:41 +00:00
|
|
|
``` text
|
2021-10-19 16:14:14 +00:00
|
|
|
┌─argMin(user, salary)─┬─argMin(tuple(user, salary), salary)─┐
|
|
|
|
│ worker │ ('worker',1000) │
|
|
|
|
└──────────────────────┴─────────────────────────────────────┘
|
2021-02-02 12:00:41 +00:00
|
|
|
```
|