BIT_AND

Applies to: ✅ Data 360 SQL ✅ Tableau Hyper API

Computes the bitwise AND of all non-null input values.

Syntax 

1bit_and(<expression>)

Arguments 

Required 

  • <expression>: An expression of an integral type.

Returns 

Returns the same type as the argument. Returns NULL if no non-null input values exist.

Considerations 

  • NULL values are ignored in the calculation.
  • Returns NULL when all input values are NULL or the set is empty.
  • Useful for checking if specific bits are set across all values.

Examples 

Bitwise AND of Values 

Compute the bitwise AND of a column.

1SELECT bit_and(flags) AS common_flags
2FROM permissions;

Check Common Bits 

Find bits that are set in all rows.

1SELECT bit_and(status_code) AS common_status_bits
2FROM system_logs
3WHERE event_type = 'error';

Related Documentation