Skip to main content

BIT_OR

Aggregate Function. Performs an OR operation on each bit between expressions. SinceBIT_OR is an aggregate function it can be used with the GROUP BY clause.

Syntax

BIT_OR  (<expr1>, <expr2>)

Arguments

  • expression: expressions must be integer data types.

Return Type

This will result in a one if two of the corresponding bits are different.  If the bits are the same it will return a zero.

Examples

CREATE TABLE numeric_sample (group_name varchar(10), ltr_val int);
INSERT INTO numeric_sample values
  ('alpha', 111), ('beta', 110), ('gamma', 000), ('delta', 001);

SELECT group_name, BIT_OR(01) FROM numeric_sample GROUP BY group_name;
+-------------------------+
|group_name | BIT_AND(01) |
+-------------------------+
|alpha      | 1           |
+-----------|-------------+
|beta       | 1           |
+-----------|-------------+
|gamma      | 1           |
+-----------|-------------+
|delta      | 1           |
+-----------|-------------+