bool_and aggregate function (Databricks SQL)

Returns true if all values in expr are true within the group.

Syntax

bool_and(expr) [FILTER ( WHERE cond ) ]

Arguments

  • expr: A BOOLEAN expression.

  • cond: An optional boolean expression filtering the rows used for aggregation.

Returns

A BOOLEAN.

Examples

> SELECT bool_and(col) FROM VALUES (true), (true), (true) AS tab(col);
 true
> SELECT bool_and(col) FROM VALUES (NULL), (true), (true) AS tab(col);
 true
> SELECT bool_and(col) FROM VALUES (true), (false), (true) AS tab(col);
 false