Applies to: ✅ Data 360 SQL ✅ Tableau Hyper API
Returns an arbitrary value from the set of input values. The result is non-deterministic.
Syntax
any_value(<expression>)
Arguments
Required
<expression>: An expression of any type.
Returns
Returns a value of the same type as the input expression. Returns NULL if no rows are selected.
Considerations
- The value returned is implementation-defined and non-deterministic.
- Useful when you need any value from a group but don't care which one.
- Returns NULL when applied to an empty set.
Examples
Get Any Value from Group
Select an arbitrary value for each group.
SELECT department, any_value(employee_name) AS sample_employee
FROM employees
GROUP BY department;
Returns one employee name per department (which one is not guaranteed).