Skip to main content

BOOL_AND aggregate function

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

Syntax

BOOL_AND( [DISTINCT] expr )

Arguments

  • expr: A BOOLEAN expression

Returns

A BOOLEAN.

Examples

> SELECT BOOL_AND(col) FROM (SELECT true AS col UNION ALL SELECT true UNION ALL SELECT true);
true

> SELECT BOOL_AND(col) FROM (SELECT NULL AS col UNION ALL SELECT true UNION ALL SELECT true);
true

> SELECT BOOL_AND(col) FROM (SELECT true AS col UNION ALL SELECT false UNION ALL SELECT true);
false

> SELECT BOOL_AND(DISTINCT col) FROM (SELECT true AS col UNION ALL SELECT false UNION ALL SELECT true);
false