COVAR_POP() GROUP BY ...
All functions > GROUP BY > COVAR_POP() GROUP BY ...
Returns the population covariance between two expressions.
Syntax
COVAR_POP(expr_y, expr_x) [ FILTER (WHERE condition) ] [ GROUP BY feature [, feature ...] ]
Notes
- Computes the population covariance (divides by N)
- NULL values in either expression are excluded from the calculation
- Returns NULL if fewer than 2 non-NULL pairs exist
Examples
FeatureQL
SELECT
f1 := ZIP(ARRAY[1, 2, 3] AS x, ARRAY[2, 4, 6] AS y).TRANSFORM(SELECT COVAR_POP(y, x)).UNWRAP_ONE() -- Population covariance
;Result
| f1 VARCHAR |
|---|
| 1.3333333333333333 |