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

BITOR_AGG

Returns the bitwise OR 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:
BITORAGG, BIT_OR_AGG, BIT_ORAGG
See also:

BITAND_AGG , BITXOR_AGG

BITOR

Syntax

BITOR_AGG( <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.
  • The DISTINCT keyword can be specified for these functions, but it does not have any effect.

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 bitor_agg(k), bitor_agg(d), bitor_agg(s1) from bitwise_example;

---------------+---------------+----------------+
 bitor_agg(k)  | bitor_agg(d)  | bitor_agg(s1)  |
---------------+---------------+----------------+
 31            | 15            | 14             |
---------------+---------------+----------------+
select s2, bitor_agg(k), bitor_agg(d) from bitwise_example group by s2;

--------+----------------+---------------+
   s2   |  bitor_agg(k)  | bitor_agg(d)  |
--------+----------------+---------------+
 one    | 15             | 1             |
 two    | 30             | 7             |
 null   | 14             | [NULL]        |
 nine   | [NULL]         | 9             |
--------+----------------+---------------+
select bitor_agg(s2) from bitwise_example;

FAILURE: Numeric value 'one' is not recognized