Skip to main content

COVAR_SAMP

Aggregate function.

The covar_samp() function returns the sample covariance (Σ((x - x̅)(y - y̅)) / (n - 1)) of two data columns.

caution

NULL values are not counted.

Syntax

COVAR_SAMP(expr0, expr1)

Arguments

ArgumentsDescription
expression0Any numerical expression
expression1Any numerical expression

Return Type

float64, when n <= 1, returns +∞.

Examples

SELECT covar_samp(number, number) from (SELECT * from numbers_mt(2) order by number asc);
+----------------------------+
| covar_samp(number, number) |
+----------------------------+
| 0.5 |
+----------------------------+