CORR() GROUP BY ...

All functions > GROUP BY > CORR() GROUP BY ...

Returns the Pearson correlation coefficient between two expressions.

Syntax

CORR(expr_y, expr_x)
 [ FILTER (WHERE condition) ]
  [ GROUP BY feature [, feature ...] ]

Notes

  • Returns a value between -1 (perfect negative correlation) and 1 (perfect positive correlation)
  • NULL values in either expression are excluded from the calculation
  • Returns NULL if fewer than 2 non-NULL pairs exist

Examples

FeatureQL
SELECT
    -- Pearson correlation on a perfect linear pair
    f1 := ZIP(ARRAY(1, 2, 3) AS x, ARRAY(2, 4, 6) AS y).TRANSFORM(
        SELECT CORR(y, x)
    ).UNWRAP_ONE()
;
Result
f1 VARCHAR
1.0

Last update at: 2026/06/20 10:08:10