Definition:

In Oracle PL/SQL, the function **REGR_SXY** is an analytic function used to generate statistics for data diagnostics based on covariance of both dependent and independent variables of regression line. It returns the sum of products of the dependent and independent variables and can be used to evaluate the statistical validity of a regression model. It takes two numeric inputs and returns a numeric output based on the formula shown below:

REGR_COUNT(x,y) * COVAR_POP(x,y)

Note that the pairs having any argument's value as NULL are eliminated, but the final result might be NULL as per the above computation.

**Example Syntax**

REGR_SXY(x,y)

In the syntax, 'x' is referred to as the *dependent* variable and 'y' is referred to as the *independent* variable of the Regression Line.

**Example Usage**

The SQL query below demonstrates the use of REGR_SXY.

SELECT deptno, sal, **REGR_SXY**(deptno, sal) OVER (partition by deptno) "REGR_SXY"

FROM employee

/

DEPTNO SAL REGR_SXY

----------- ---------- ----------

100 2300 0

100 3810 0

100 3810 0

100 8300 0

100 0

100 2300 0

110 3900 0

110 8210 0

110 2900 0

120 4500 0

120 8300 0

120 1200 0

120 3200 0

13 rows selected.

Related Links:

Related Code Snippets:

- REGR_SXY - REGR_SXY makes the following computation after eliminating NULL (expr1, expr2) pairs:
...