Training
Module
Use built-in functions and GROUP BY in Transact-SQL - Training
Use built-in functions and GROUP BY in Transact-SQL
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
regr_sxx
aggregate functionApplies to: Databricks SQL
Databricks Runtime 11.3 LTS and above
Returns the sum of squares of the xExpr
values of a group where xExpr
and yExpr
are NOT NULL
.
regr_sxx( [ALL | DISTINCT] yExpr, xExpr) [FILTER ( WHERE cond ) ]
This function can also be invoked as a window function using the OVER
clause.
yExpr
: A numeric expression, the dependent variable.xExpr
: A numeric expression, the independent variable.cond
: An optional Boolean expression filtering the rows used for the function.The result type is DOUBLE
.
Any nulls within the group are ignored. If a group is empty or consists only of nulls, the result is NULL
.
If DISTINCT
is specified, the result is computed after duplicates are removed.
regr_sxx(y, x)
is a synonym for regr_count(y, x) * var_pop(x)
.
> SELECT typeof(regr_sxx(y, x)) FROM VALUES (1, 2), (2, 3), (2, 3), (null, 4), (4, null) AS T(y, x);
1.6666666666666666
Training
Module
Use built-in functions and GROUP BY in Transact-SQL - Training
Use built-in functions and GROUP BY in Transact-SQL