# `COVAR_POP`

**Applies to:** ✅ Data 360 SQL ✅ Tableau Hyper API

Computes the population covariance between two sets of values.

## Syntax

```sql
covar_pop(<Y>, <X>)
```

## Arguments

### Required

- `<Y>`: A `double precision` expression.
- `<X>`: A `double precision` expression.

## Returns

Returns a `double precision` value representing the population covariance. Returns NULL if the computation is meaningless.

## Considerations

- Returns NULL if there are no rows where both X and Y are non-null.
- Population covariance uses N in the denominator.
- Use `COVAR_SAMP` for sample covariance (uses N-1 in the denominator).

## Examples

### Calculate Population Covariance

Find the population covariance between two variables.

```sql
SELECT covar_pop(height, weight) AS covariance
FROM measurements;
```

### Covariance by Group

Calculate covariance for each group.

```sql
SELECT region, covar_pop(sales, temperature) AS sales_temp_cov
FROM regional_data
GROUP BY region;
```

## Related Documentation

- [COVAR_SAMP](/docs/data/data-cloud-query-guide/references/dc-sql-reference/covar-samp.md)
- [CORR](/docs/data/data-cloud-query-guide/references/dc-sql-reference/corr.md)
- [Aggregate Functions](/docs/data/data-cloud-query-guide/references/dc-sql-reference/aggregate.md)
