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

# `covar_pop` 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 population covariance of number pairs in a group.

## Syntax

```
covar_pop ( [ALL | DISTINCT] expr1, expr2 ) [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

* `expr1`: An expression that evaluates to a numeric.
* `expr2`: An expression that evaluates to a numeric.
* `cond`: An optional boolean expression filtering the rows used for aggregation.

## Returns

A `DOUBLE`.

If `DISTINCT` is specified the function operates only on a unique set of `expr1`, `expr2` pairs.

## Examples

```sql
> SELECT covar_pop(c1, c2) FROM VALUES (1,1), (2,2), (2,2), (3,3) AS tab(c1, c2);
 0.5

> SELECT covar_pop(DISTINCT c1, c2) FROM VALUES (1,1), (2,2), (2,2), (3,3) AS tab(c1, c2);
 0.6666666666666666
```

## Related functions

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