Skip to main content


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


BIT_AND (<expr1>, <expr2>)


  • expression: expressions must be integer data types.

Return Type

Returns the same value as the argument datatype. This will result in a one if the first and second bits are both one. Otherwise, the result will return a zero.


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_AND(000) FROM numeric_sample GROUP BY group_name;
|group_name | BIT_AND(000)|
|alpha      | 0           |
|beta       | 0           |
|gamma      | 0           |
|delta      | 0           |