4. Understanding the Elements of SQL Statements : SQL Functions : Aggregate Functions : Regression and Correlation Analysis Aggregate Functions
 
Share this page                  
Regression and Correlation Analysis Aggregate Functions
The following aggregate functions perform a variety of regression and correlation analysis.
Syntax is as follows:
function_name(indep_parm, dep_parm)
where function_name denotes the function name and the first argument is the independent variable and the second argument is the dependent variable.
Functions for regression and correlation analysis are as follows:
CORR
CORR(indep_parm, dep_parm)
Result type: FLOAT
Returns correlation coefficient (ratio of the population covariance divided by the product of the population standard deviation of the independent variable and the population standard deviation of the dependent variable).
COVAR_POP
COVAR_POP(indep_parm, dep_parm)
Result type: FLOAT
Returns population covariance (sum of the products of the difference of the independent variable from its mean, times the difference of the dependent variable from its mean, divided by the number of rows).
COVAR_SAMP
COVAR_SAMP(indep_parm, dep_parm)
Result type: FLOAT
Returns sample covariance (sum of the products of the difference of the independent variable from its mean, times the difference of the dependent variable from its mean, divided by the number of rows minus 1).
REGR_AVGX
REGR_AVGX(indep_parm, dep_parm)
Result type: FLOAT
Returns average of the independent variables.
REGR_AVGY
REGR_AVGY(indep_parm, dep_parm)
Result type: FLOAT
Returns average of the dependent variables.
REGR_COUNT
REGR_COUNT(indep_parm, dep_parm)
Result type: INTEGER
Returns count of rows with non-null values for both dependent and independent variables.
REGR_INTERCEPT
REGR_INTERCEPT(indep_parm, dep_parm)
Result type: FLOAT
Returns Y-intercept of the least-squares-fit linear equation determined by the (independent variable, dependent variable) pairs.
REGR_R2
REGR_R2(indep_parm, dep_parm)
Result type: FLOAT
Returns square of the correlation coefficient.
REGR_SLOPE
REGR_SLOPE(indep_parm, dep_parm)
Result type: FLOAT
Returns slope of the least-squares-fit linear equation determined by the (independent variable, dependent variable) pairs.
REGR_SXX
REGR_SXX(indep_parm, dep_parm)
Result type: FLOAT
Returns the sample corrected sum of the squares of the independent variable.
REGR_SXY
REGR_SXY(indep_parm, dep_parm)
Result type: FLOAT
Returns sum of the product of the independent variable and the dependent variable.
REGR_SYY
REGR_SYY(indep_parm, dep_parm)
Result type: FLOAT
Returns the sample corrected sum of the squares of the dependent variable.