v.25.11New Feature

New aggregate functions argAndMin and argAndMax

New aggregate functions argAndMin and argAndMax that return the argument and the corresponding extreme value. In previous versions it was also possible by using a tuple as an argument. #89884 (AbdAlRahman Gad).
Introduces new aggregate functions argAndMin and argAndMax that return both the argument and its corresponding minimum or maximum value.

Why it matters

To provide a more direct and efficient way to retrieve the argument associated with the minimum or maximum value in aggregation queries, simplifying queries that previously required using tuples as arguments.

How to use it

Use the aggregate functions argAndMin(arg, value) and argAndMax(arg, value) in your SELECT queries to get the argument combined with the minimum or maximum of the corresponding values, for example:

SELECT argAndMin(user_id, score) FROM table;
SELECT argAndMax(user_id, score) FROM table;