---
title: bit_xor aggregate function
description: Learn the syntax of the bit\_xor function of the SQL language in Databricks SQL and Databricks Runtime.
canonical_url: https://docs.databricks.com/aws/en/sql/language-manual/functions/bit_xor
---

# `bit_xor` aggregate function

**Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks SQL ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime

Returns the bitwise `XOR` of all input values in the group.

## Syntax

```
bit_xor ( [ALL | DISTINCT] expr ) [FILTER ( WHERE cond ) ]
```

This function can also be invoked as a [window function](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-window-functions.md) using the `OVER` clause.

## Arguments

* `expr`: An expression that evaluates to an integral numeric.
* `cond`: An optional boolean expression filtering the rows used for aggregation.

## Returns

The result type matches the argument type.

If `DISTINCT` is specified the aggregate operates only on distinct values.

## Examples

```sql
> SELECT bit_xor(col) FROM VALUES (3), (3), (5) AS tab(col);
 5

> SELECT bit_xor(DISTINCT col) FROM VALUES (3), (3), (5) AS tab(col);
 6
```

## Related

* [`bit_or` aggregate function](https://docs.databricks.com/aws/en/sql/language-manual/functions/bit_or.md)
* [`bit_and` aggregate function](https://docs.databricks.com/aws/en/sql/language-manual/functions/bit_and.md)
* [`some` aggregate function](https://docs.databricks.com/aws/en/sql/language-manual/functions/some.md)
* [Window functions](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-window-functions.md)
