ARG_MIN (Lakehouse v1)
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.
Analyze Syntax
Section titled “Analyze Syntax”func.arg_min(<expr>)Analyze Examples
Section titled “Analyze Examples”func.arg_min(table.name, table.score).alias('student_name')
| student_name ||--------------|| Charlie |SQL Syntax
Section titled “SQL Syntax”ARG_MIN(<arg>, <val>)Arguments
Section titled “Arguments”| Arguments | Description |
|---|---|
<arg> | Argument of any data type that PlaidCloud Lakehouse supports |
<val> | Value of any data type that PlaidCloud Lakehouse supports |
Return Type
Section titled “Return Type”arg value that corresponds to minimum val value.
matches arg type.
SQL Examples
Section titled “SQL Examples”Let’s create a table students with columns id, name, and score, and insert some data:
CREATE TABLE students ( id INT, name VARCHAR, score INT);
INSERT INTO students (id, name, score) VALUES (1, 'Alice', 80), (2, 'Bob', 75), (3, 'Charlie', 90), (4, 'Dave', 80);Now, we can use ARG_MIN to find the name of the student with the lowest score:
SELECT ARG_MIN(name, score) AS student_nameFROM students;Result:
| student_name ||--------------|| Charlie |