---
title: bool_and aggregate function
description: Learn the syntax of the bool\_and function of the SQL language in Databricks SQL and Databricks Runtime.
canonical_url: https://docs.databricks.com/gcp/en/sql/language-manual/functions/bool_and
---

# `bool_and` aggregate function

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

Returns `true` if all values in `expr` are true within the group.
This function is a synonym for [`every` aggregate function](https://docs.databricks.com/gcp/en/sql/language-manual/functions/every.md).

## Syntax

```
bool_and(expr) [FILTER ( WHERE cond ) ]
```

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

## Arguments

* `expr`: A BOOLEAN expression.
* `cond`: An optional boolean expression filtering the rows used for aggregation.

## Returns

A BOOLEAN.

## Examples

```sql
> SELECT bool_and(col) FROM VALUES (true), (true), (true) AS tab(col);
 true

> SELECT bool_and(col) FROM VALUES (NULL), (true), (true) AS tab(col);
 true

> SELECT bool_and(col) FROM VALUES (true), (false), (true) AS tab(col);
 false

> SELECT bool_and(col1) FILTER(WHERE col2 = 1)
    FROM VALUES (true, 1), (false, 2), (true, 1) AS tab(col1, col2);
 true
```

## Related functions

* [`bool_or` aggregate function](https://docs.databricks.com/gcp/en/sql/language-manual/functions/bool_or.md)
* [`every` aggregate function](https://docs.databricks.com/gcp/en/sql/language-manual/functions/every.md)
* [Window functions](https://docs.databricks.com/gcp/en/sql/language-manual/sql-ref-window-functions.md)
