---
schema_version: "1"
id: 95518e16eae389b5e869916af46a618759df26e2389e5a6b7648a7284dbb049e
title: BIT_AND
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/data-cloud/data-cloud-query-guide/references/data-cloud-sql-reference/aggregate-func/bit-and.md
canonical_url: https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/bit-and.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 9cea175dc946d45810868dc7eaa66f937478e723d98dd47056b802aff00907c4
products:
  - Data 360 Query Guide
  - Data 360 Developer Documentation
---
# `BIT_AND`

**Applies to:** ✅ Data 360 SQL ✅ Tableau Hyper API

Computes the bitwise `AND` of all non-null input values.

## Syntax

```sql
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.

```sql
SELECT bit_and(flags) AS common_flags
FROM permissions;
```

### Check Common Bits

Find bits that are set in all rows.

```sql
SELECT bit_and(status_code) AS common_status_bits
FROM system_logs
WHERE event_type = 'error';
```

## Related Documentation

- [BIT_OR](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/bit-or.md)
- [Aggregate Functions](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/aggregate.md)
