COVAR_SAMP() OVER ...

All functions > WINDOW FUNCTION > COVAR_SAMP() OVER ...

Returns the sample covariance over the window frame.

Syntax

COVAR_SAMP(expr_y, expr_x) OVER ([PARTITION BY expr [, ...]] [ORDER BY sort_item [, ...]] [ROWS|RANGE|GROUPS frame])

Notes

  • Computes sample covariance (divides by N-1) over a window
  • NULL values in either expression are excluded

See also

Examples

FeatureQL
SELECT
    f1 := ZIP(ARRAY[1,2,3] AS id, ARRAY[1.0E0,2.0E0,3.0E0] AS y, ARRAY[1.0E0,2.0E0,4.0E0] AS x).TRANSFORM(SELECT COVAR_SAMP(y, x) OVER (ORDER BY id ASC)).UNWRAP() -- Sample covariance over the frame
;
Result
f1 ARRAY
[null, 0.5, 1.5]

Last update at: 2026/05/26 17:22:09