- Categories:
Aggregate functions (Boolean) , Window functions , Conditional expression functions
BOOLXOR_AGG¶
Returns TRUE if exactly one Boolean record in the group evaluates to TRUE.
If all records in the group are NULL, or if the group is empty, the function returns NULL.
- See also:
Syntax¶
Aggregate function
Window function
Arguments¶
exprThe input expression must be an expression that can be evaluated to a boolean or converted to a boolean.
partition_exprThis column or expression specifies how to separate the input into partitions (sub-windows).
Returns¶
This function returns a value of type BOOLEAN.
Usage notes¶
Numeric values are converted to
TRUEif they are non-zero.String and binary values aren’t supported because they can’t be converted to Boolean values.
When this function is called as a window function, it does not support:
An ORDER BY clause within the OVER clause.
Explicit window frames.
Examples¶
The following example shows that boolxor_agg returns true when exactly one of the input values is true.
Create and load the table:
Display the data:
Query the data:
Window function
This example is similar to the previous example, but it shows usage as a window function, with the input rows split into two partitions (one for IDs greater than 0 and one for IDs less than or equal to 0). Additional data was added to the table.
Add rows to the table:
Display the data:
Query the data:
Error example
If this function is passed strings that cannot be converted to Boolean, the function will give an error: