This aggregate function returns a logical OR of Boolean
argument values for each row of the result set.
BOOLEAN_OR([ALL | DISTINCT] expression)
Returns: Boolean
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.NULL
s or unknowns are ignored, unless only values in the group or table are NULL
s. See Example 1.boolean_or()
function does not support the OVER
clause, and therefore it cannot be used as an analytic function.Here the explanation for the results in this example:
x=1
has all values of b
set to false
; therefore, BOOLEAN_OR()
of column b
evaluates to false
. x=2
and x=3
have at least one value of b
that is true
; therefore, BOOLEAN_OR()
for these groups evaluates to true
.x=4
returns false
, and the group with x=5
returns true
, because BOOLEAN_OR()
ignores the null
values in these groups.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 | +---+---------------+