Training
Module
Summarizing data: Aggregate functions and grouping - Training
Analyze data in PostgreSQL with aggregate functions and grouping. Learn COUNT, SUM, AVG, and filter results using GROUP BY and HAVING.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
any_value
aggregate functionApplies to: Databricks SQL
Databricks Runtime 11.3 LTS and above
Returns some value of expr
for a group of rows. This function is non-deterministic.
any_value(expr[, ignoreNull]) [FILTER ( WHERE cond ) ] [ IGNORE NULLS | RESPECT NULLS ]
This function can also be invoked as a window function using the OVER
clause.
expr
: An expression of any type.ignoreNull
: An optional BOOLEAN literal defaulting to false. The default for ignoreNull
is false.cond
: An optional boolean expression filtering the rows used for aggregation.IGNORE NULLS
or RESPECT NULLS
: When IGNORE NULLS
is used or ignoreNull
is true
any expr
value that is NULL is ignored.
The default is RESPECT NULLS
.The result has the same type as expr
.
> SELECT any_value(col) FROM VALUES (10), (5), (20) AS tab(col);
10
-- Subsequent executions may yield a different results
> SELECT any_value(col) FROM VALUES (10), (5), (20) AS tab(col);
20
> SELECT any_value(col) FROM VALUES (NULL), (5), (20) AS tab(col);
NULL
> SELECT any_value(col) IGNORE NULLS FROM VALUES (NULL), (5), (20) AS tab(col);
5
Training
Module
Summarizing data: Aggregate functions and grouping - Training
Analyze data in PostgreSQL with aggregate functions and grouping. Learn COUNT, SUM, AVG, and filter results using GROUP BY and HAVING.
Events
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign in