BOOL_OR()
Returns TRUE if at least one value in the group is TRUE (logical OR across rows).
Description
BOOL_OR is an aggregate function that returns TRUE if any row in the group
satisfies the condition (a logical OR across rows). Use it for questions like
"did any employee in this department get a bonus?"
Syntax
BOOL_OR(expression)Parameters
| Name | Description | Optional |
|---|---|---|
| expression | A boolean expression evaluated per row. | No |
Return Type
Returns a BOOLEAN. An empty group typically returns NULL (or FALSE in some
engines for an empty OR).
Examples
Loading playground environment...
Loading playground environment...
Great for existence checks
BOOL_OR(condition) is a clean way to ask "does any row match?" inside a
grouped query, without a subquery.
Common Mistakes
- Confusing with OR in WHERE.
BOOL_ORaggregates across rows;ORinWHEREtests a single row. - Empty groups. May return NULL rather than FALSE, guard if needed.
- Non-boolean input. The argument must be boolean.
Related Functions
See also: BOOL_AND, EVERY.
Cite this resource
SQLSimplified. "BOOL_OR() SQL Function". Available at: https://sqlsimplified.online/reference/bool-or