Scalar function
Aliases: bitand
Returns NULL when either operand is NULL.
Syntax
Numeric values
- Takes exactly two numeric operands. Noninteger numbers are converted to BIGINT and must fit that type.
Arguments
Bitwise and integer
Bitwise and numeric cast
Returns
- Type: bitwise and integer: TINYINT, SMALLINT, INTEGER or BIGINT: the wider signed integer input type; bitwise and numeric cast: BIGINT when at least one operand is a noninteger numeric value
- Possible values: Each output bit is 1 only when both corresponding input bits are 1.
- NULL behavior: Returns NULL when either operand is NULL.
Bitwise and integer
- Type: TINYINT, SMALLINT, INTEGER or BIGINT: the wider signed integer input type
- Possible values: Each output bit is 1 only when both corresponding input bits are 1.
- NULL behavior: Returns NULL when either integer operand is NULL.
Bitwise and numeric cast
- Type: BIGINT when at least one operand is a noninteger numeric value
- Possible values: The bitwise AND of the converted signed BIGINT operands.
- NULL behavior: NULL numeric inputs remain NULL through conversion and produce NULL.
Properties
Usage notes
- Integer operands are converted to a common integer type. BITWISE_AND also converts noninteger numeric inputs to BIGINT; BITAND does not accept those inputs.
- INTEGER and INT mean the same type; STRING means VARCHAR text. NULL can be used with a supported type. Cast NULL explicitly when its type would otherwise be unclear.
Examples
Example values
Keep the common set bits
In binary, 1100 AND 1010 is 1000, which is 8.
Limitations
- BITWISE_AND accepts exactly two numeric operands. BINARY operands and a third padside argument are not supported; use BITAND for binary values.
- BITWISE_AND converts noninteger numeric operands to BIGINT before the bitwise operation. Values that cannot be converted can raise an error. Query tools may report the first argument’s type even when the result is BIGINT.
Last modified on October 15, 2026