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

# BIT_XOR

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

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

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"}}
bit_xor([DISTINCT] value)
```

### Window

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
bit_xor(value) OVER ([PARTITION BY key] [ORDER BY ordering_key] [ROWS frame])
```

* RANGE frames with a numeric or time offset are not supported. Use unique ORDER BY values for calculations that advance one row at a time. DISTINCT is not supported in these window forms.

## 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 (Use the ROWS forms shown here; RANGE offsets are not supported.) |
| 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 bit_xor("value") AS result FROM t;
```

| result |
| - |
| 6 |

### Ignore NULLs

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
WITH t("value") AS (VALUES (1), (CAST(NULL AS INTEGER)), (2)) SELECT bit_xor("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 bit_xor("value") AS result FROM t;
```

| result |
| - |
| NULL |

## Limitations

* BIT\_XOR does not support DISTINCT in sliding windows.


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