BIT_OR
Description
The BIT_OR function is used to calculate the bitwise OR result of a set of integer expressions. This function can handle integer data types including TINYINT, SMALLINT, INT, and BIGINT. By using this function, users can perform bitwise operations on a set of integers to obtain a new integer value.
Parameter Description
- expr: Represents the integer expression to be bitwise OR operated. The parameter type is required to be an integer type, including TINYINT, SMALLINT, INT, and BIGINT.
- distinct (optional): When set to distinct, the function will calculate the bitwise OR result of the deduplicated set. If distinct is not set, the bitwise OR operation is performed on all expressions, including duplicate values.
Return Result
- The return value type is consistent with the parameter type, i.e., integer type (TINYINT, SMALLINT, INT, or BIGINT).
- If all input parameters are NULL, NULL is returned.
- For cases where distinct is not set, NULL values are not included in the calculation.
- For cases where distinct is set, NULL values are also not included in the calculation.
Usage Example
- Calculate the bitwise OR result of a set of values (distinct not set):
- Calculate the bitwise OR result of a set of values after removing duplicates (set distinct):
- Calculate the bitwise OR result of numeric values containing NULL (distinct not set):
- Calculate the bitwise OR result of distinct numerical values containing NULL (set distinct):