REGR_INTERCEPT() GROUP BY ...

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

Returns the y-intercept of the linear regression line fitted to (x, y) pairs.

Syntax

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

Notes

  • Equivalent to AVG(y) - REGR_SLOPE(y, x) * AVG(x)
  • NULL values in either expression are excluded from the calculation
  • Returns NULL if VAR_POP(x) is zero or fewer than 2 non-NULL pairs exist

Examples

FeatureQL
SELECT
    f1 := ZIP(ARRAY[1, 2, 3] AS x, ARRAY[2, 4, 6] AS y).TRANSFORM(SELECT REGR_INTERCEPT(y, x)).UNWRAP_ONE() -- Regression intercept for y = 2x through the origin
;
Result
f1 VARCHAR
0.0

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