Categories:
Aggregate Functions (Bitwise) , Window Functions , Bitwise Expression Functions

BITXOR_AGG

Returns the bitwise XOR value of all non-NULL numeric records in a group. If all records inside the group are NULL, or if the group is empty, the function returns NULL.

Aliases:
BITXORAGG , BIT_XOR_AGG, BIT_XORAGG
See also:

BITAND_AGG , BITOR_AGG

BITXOR

Syntax

BITXOR_AGG( [ DISTINCT ] <expr> )

Usage Notes

  • Numeric values are aggregated to the nearest integer data type. Decimal and floating point values are rounded to the nearest integer before aggregation.
  • Aggregating a character/text column (data type VARCHAR, CHAR, STRING, etc.) implicitly casts the input values to FLOAT, then rounds the values to the nearest integer. If the cast is not possible, the value is treated as NULL.

Examples

Using the bitwise_example table created for the BITAND_AGG examples:

select * from bitwise_example;

--------+----------+--------+------+
   K    |    D     |   S1   |  S2  |
--------+----------+--------+------+
 15     | 1.10000  | 12     | one  |
 26     | 2.90000  | 10     | two  |
 12     | 7.10000  | 7.9    | two  |
 14     | [NULL]   | [NULL] | null |
 8      | [NULL]   | [NULL] | null |
 [NULL] | 9.10000  | 14     | nine |
--------+----------+--------+------+
select bitxor_agg(k), bitxor_agg(d), bitxor_agg(s1) from bitwise_example;

----------------+----------------+-----------------+
 bitxor_agg(k)  | bitxor_agg(d)  | bitxor_agg(s1)  |
----------------+----------------+-----------------+
 31             | 12             | 0               |
----------------+----------------+-----------------+
select s2, bitxor_agg(k), bitxor_agg(d) from bitwise_example group by s2;

--------+-----------------+----------------+
   s2   |  bitxor_agg(k)  | bitxor_agg(d)  |
--------+-----------------+----------------+
 one    | 15              | 1              |
 two    | 22              | 4              |
 null   | 6               | [NULL]         |
 nine   | [NULL]          | 9              |
--------+-----------------+----------------+
select bitxor_agg(s2) from bitwise_example;

FAILURE: Numeric value 'one' is not recognized