This aggregate function returns a logical OR of Boolean argument values for each row of the result set.



Returns: Boolean

Usage Notes and Restrictions

  • By default, returns a single Boolean for the entire result set. To include other columns or values in the result set, or to produce multiple Boolean values for subsets of rows, include a GROUP BY clause in the query.
  • The function adheres to PostgreSQL-style semantics, where NULLs or unknowns are ignored, unless only values in the group or table are NULLs. See Example 1.
  • The boolean_or() function does not support the OVER clause, and therefore it cannot be used as an analytic function.

Example: BOOLEAN_OR() with GROUP BY Clause

Here the explanation for the results in this example:

  • The group that corresponds to x=1 has all values of b set to false; therefore, BOOLEAN_OR() of column b evaluates to false.
  • The groups that correspond to x=2 and x=3 have at least one value of b that is true; therefore, BOOLEAN_OR() for these groups evaluates to true.
  • The group with x=4 returns false, and the group with x=5 returns true, because BOOLEAN_OR() ignores the null values in these groups.
  • The group with x=6 returns null because the only values of b in that group are null.
create table t2 (x int, b boolean);
insert into t2 values (1, false), (1, false), (2, true), (2, true), (3, false), (3, true), (4, false), (4, null), (5, true), (5, null), (6, null), (6, null);
[localhost:21000] > select x, boolean_or(b) from t2 group by x;
Query: select x, boolean_or(b) from t2 group by x
| x | boolean_or(b) |
| 4 | false         |
| 2 | true          |
| 6 | NULL          |
| 1 | false         |
| 5 | true          |
| 3 | true          |