ClickHouse/docs/zh/sql-reference/aggregate-functions/reference/argmin.md

915 B

slug sidebar_position
/zh/sql-reference/aggregate-functions/reference/argmin 105

argMin

语法: argMin(arg, val)argMin(tuple(arg, val))

计算 val 最小值对应的 arg 值。

示例:

输入表:

┌─user─────┬─salary─┐
│ director │   5000 │
│ manager  │   3000 │
│ worker   │   1000 │
└──────────┴────────┘

查询:

SELECT argMin(user, salary), argMin(tuple(user, salary), salary) FROM salary;

结果:

┌─argMin(user, salary)─┬─argMin(tuple(user, salary), salary)─┐
│ worker               │ ('worker',1000)                     │
└──────────────────────┴─────────────────────────────────────┘