> ## Documentation Index
> Fetch the complete documentation index at: https://docs.e6data.com/llms.txt
> Use this file to discover all available pages before exploring further.

# BITORAGG

> Returns the bitwise OR of non-NULL integer values.

<div className="e6-meta"><span className="e6-eyebrow e6-eyebrow--quiet">Aggregate · Window</span></div>

**Aliases:** [`bit_or`](/query/sql/functions/aggregate/bit_or)

NULLs are ignored; an all-NULL group or frame returns NULL.

## Syntax

A window function keeps each input row and adds a result for that row. `PARTITION BY` groups rows with matching values; without it, all input rows form one group.

### Aggregate

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
bitoragg([DISTINCT] value)
```

### Window

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
bitoragg(value) OVER ([PARTITION BY key] [ORDER BY ordering_key] [ROWS BETWEEN UNBOUNDED PRECEDING AND bound])
```

* Use a frame that includes all rows in the group or starts at the first row (`UNBOUNDED PRECEDING`). Sliding frames that drop earlier rows are not supported. RANGE frames with a numeric or time offset are not supported.

## Arguments

### Aggregate and window

| Name | Type | Required | Description |
| - | - | - | - |
| value | TINYINT, SMALLINT, INTEGER or BIGINT | Yes | Integer whose bits are combined. |

## Returns

* Type: Same SQL type as value
* NULL behavior: NULLs are ignored; an all-NULL group or frame returns NULL.
* Empty input: Returns NULL on an empty global aggregate or empty frame.

## Properties

| Property | Value |
| - | - |
| Deterministic | Yes |
| Supports DISTINCT | Partial (Grouped aggregation only; see the window limitations below.) |
| Supports window usage | Yes |
| Supports window frames | Partial (The frame must start at the first row in the group. See Syntax.) |
| Exact result | Yes |

## Usage notes

* Use DISTINCT in grouped aggregation only. It does not provide duplicate removal in a window call.

## Examples

### Combine bits

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
WITH t("value") AS (VALUES (3), (5)) SELECT bitoragg("value") AS result FROM t;
```

| result |
| - |
| 7 |

### Ignore NULLs

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
WITH t("value") AS (VALUES (1), (CAST(NULL AS INTEGER)), (2)) SELECT bitoragg("value") AS result FROM t;
```

| result |
| - |
| 3 |

### All NULL values

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
WITH t("value") AS (VALUES (CAST(NULL AS INTEGER)), (CAST(NULL AS INTEGER))) SELECT bitoragg("value") AS result FROM t;
```

| result |
| - |
| NULL |

## Limitations

* FLOAT, DOUBLE, and DECIMAL inputs are not supported. Cast to an integer type before calling the function if integer conversion is appropriate for your data.
* BITORAGG returns the input integer type, although query tools may report BIGINT. The reported type does not widen the returned value.
* Use a frame that includes all rows in the group or starts at the first row (`UNBOUNDED PRECEDING`). Sliding frames that drop earlier rows are not supported. RANGE frames with a numeric or time offset are not supported.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.