BIT_AND

Applies to: ✅ Data 360 SQL ✅ Tableau Hyper API

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

Syntax

bit_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.

SELECT bit_and(flags) AS common_flags
FROM permissions;

Check Common Bits

Find bits that are set in all rows.

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

Related Documentation