Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Fixed
-
0.6.0
-
None
-
None
Description
A lot of users are interested in doing "arg_min" and "arg_max". Basically, return the value of some other columns when one column's value is the max value.
The following is an example usage when this is done:
SELECT department, max(struct(salary, employee_name)) FROM compensations GROUP BY department; SELECT department, max(struct(salary, employee_name)).col2 AS employee_name FROM compensations GROUP BY department; SELECT department, sen.col1 as salary, sen.col2 as employee_name FROM ( SELECT department, max(struct(salary, employee_name)) AS sen FROM compensations GROUP BY department ) tmp