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.

!!! warning NULL values are not counted.

Syntax

covar_samp(expression0, expression1)

Arguments

ArgumentsDescription
expression0Any numerical expression
expression1Any numerical expression

Return Type

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

Examples

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