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
    -- Regression intercept for y = 2x through the origin
    f1 := ZIP(ARRAY(1, 2, 3) AS x, ARRAY(2, 4, 6) AS y).TRANSFORM(
        SELECT REGR_INTERCEPT(y, x)
    ).UNWRAP_ONE()
;
Result
f1 VARCHAR
0.0

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