ClickHouse/docs/en/sql-reference/aggregate-functions/reference/varpop.md

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

57 lines
903 B
Markdown
Raw Normal View History

---
title: "varPop"
slug: "/en/sql-reference/aggregate-functions/reference/varPop"
sidebar_position: 210
---
## varPop
Calculates the population variance:
$$
\frac{\Sigma{(x - \bar{x})^2}}{n}
$$
**Syntax**
```sql
2024-06-14 13:33:19 +00:00
varPop(x)
```
2024-06-14 13:33:19 +00:00
Alias: `VAR_POP`.
**Parameters**
2024-06-14 13:33:19 +00:00
- `x`: Population of values to find the population variance of. [(U)Int*](../../data-types/int-uint.md), [Float*](../../data-types/float.md), [Decimal*](../../data-types/decimal.md).
**Returned value**
2024-06-14 13:33:19 +00:00
- Returns the population variance of `x`. [`Float64`](../../data-types/float.md).
**Example**
Query:
```sql
DROP TABLE IF EXISTS test_data;
CREATE TABLE test_data
(
2024-06-14 13:33:19 +00:00
x UInt8,
)
ENGINE = Memory;
2024-06-14 13:33:19 +00:00
INSERT INTO test_data VALUES (3), (3), (3), (4), (4), (5), (5), (7), (11), (15);
SELECT
2024-06-14 13:33:19 +00:00
varPop(x) AS var_pop
FROM test_data;
```
Result:
```response
2024-06-14 13:33:19 +00:00
┌─var_pop─┐
│ 14.4 │
└─────────┘
```