ANY_VALUE

All functions > AGGREGATE > ANY_VALUE

Returns an arbitrary value from the group.

Syntax

ANY_VALUE(expr: T) → T
sql

Type Parameters:

  • T: Any type

Arguments

ParameterTypeRequiredDescription
exprTYesThe expression to evaluate

Returns

An arbitrary (non-deterministic) value from the group

Notes

  • Result is non-deterministic: may return different values across runs
  • Useful when you need any value from a group and don't care which one
  • More efficient than MIN() or MAX() when exact value doesn't matter
  • Returns NULL if all values in the group are NULL
  • Can be used with WHERE clause to filter before aggregation
  • Can be used with GROUP BY clause for grouped aggregation

Aliases

  • ARBITRARY

Examples

Last update at: 2025/10/13 10:23:46