Skip to main content

argMin

Calculates the arg value for a minimum val value. If there are several different values of arg for minimum values of val, returns the first of these values encountered.

Syntax

argMin(arg, val)

Arguments

  • arg β€” Argument.
  • val β€” Value.

Returned value

  • arg value that corresponds to minimum val value.

Type: matches arg type.

Example

Input table:

β”Œβ”€user─────┬─salary─┐
β”‚ director β”‚ 5000 β”‚
β”‚ manager β”‚ 3000 β”‚
β”‚ worker β”‚ 1000 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Query:

SELECT argMin(user, salary) FROM salary

Result:

β”Œβ”€argMin(user, salary)─┐
β”‚ worker β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜