regr_sxy

regr_sxy

regr_sxy 介绍

regr_sxy(y, x) - 对于组中的非空值对,返回 REGR_COUNT(y, x) * COVAR_POP(y, x),其中 y 是因变量,x 是自变量。

Examples:

> SELECT regr_sxy(y, x) FROM VALUES (1, 2), (2, 2), (2, 3), (2, 4) AS tab(y, x);
 0.75
> SELECT regr_sxy(y, x) FROM VALUES (1, 2), (2, null), (2, 3), (2, 4) AS tab(y, x);
 1.0
> SELECT regr_sxy(y, x) FROM VALUES (1, 2), (2, null), (null, 3), (2, 4) AS tab(y, x);
 1.0

Since: 3.4.0