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

# `bit_or` 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 `OR` of all input values in the group.

To aggregate bit positions into a `BINARY` bitmap use the [bitmap\_construct\_agg()](https://docs.databricks.com/aws/en/sql/language-manual/functions/bitmap_construct_agg.md) aggregate function.

To aggregate `BINARY` input values use the [bitmap\_or\_agg()](https://docs.databricks.com/aws/en/sql/language-manual/functions/bitmap_or_agg.md)] aggregate function.

## Syntax

```
bit_or(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.

## Examples

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

> SELECT bit_or(col) FILTER(WHERE col < 8) FROM VALUES (3), (5), (8) AS tab(col);
 7
```

## Related functions

* [`bit_and` aggregate function](https://docs.databricks.com/aws/en/sql/language-manual/functions/bit_and.md)
* [`bit_xor` aggregate function](https://docs.databricks.com/aws/en/sql/language-manual/functions/bit_xor.md)
* [`bitmap_construct_agg` aggregate function](https://docs.databricks.com/aws/en/sql/language-manual/functions/bitmap_construct_agg.md)
* [`bitmap_or_agg` aggregate function](https://docs.databricks.com/aws/en/sql/language-manual/functions/bitmap_or_agg.md)
* [`some` aggregate function](https://docs.databricks.com/aws/en/sql/language-manual/functions/some.md)
