Quick Search:
CODE
Oracle PL/SQL Code Library
JOBS
Find Or Post Oracle Jobs
FORUM
Oracle Discussion & Chat
 The Oracle PL/SQL REGR_AVGX Function      [Return To Index] Jump to:  
  Looking for the original pages? (formerly called "Morgan's Library") You can find them here.

Term: REGR_AVGX

Definition:
In Oracle PL/SQL, the function REGR_AVGX is a linear regression analytic function which takes two numeric inputs and calculates average of the second argument (the independent variable) of a regression line. It completely ignores the pair of values where any of the arguments is NULL.

Example Syntax:

REGR_AVGX(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 uses the REGR_AVGX function to calculate average of SAL in its partition created by DEPTNO.

sql> SELECT deptno, sal, regr_avgx(deptno, sal) OVER (partition by deptno) "REGR_AVGX"
FROM employee
/

DEPTNO SAL REGR_AVGX
----------- ---------- ----------
100 2300 4223.33333
100 3810 4223.33333
100 3810 4223.33333
100 8300 4223.33333
100 4820 4223.33333
100 2300 4223.33333
110 3900 5003.33333
110 8210 5003.33333
110 2900 5003.33333
120 4500 4300
120 8300 4300
120 1200 4300
120 3200 4300

13 rows selected.



Related Links:

Related Code Snippets:
  • REGR_AVGX - REGR_AVGX evaluates the average of the independent variable (expr2) of the regression ...
 
Home      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us 198 users online    © 2009 psoug.org
PSOUG LOGIN
Username: 
Password: 
Forgot your password?