CORRELATION aggregate function
The CORRELATION function returns the coefficient of correlation of a set of number pairs.
The schema is SYSIBM.
-
expression1
- An expression that returns a value of any built-in numeric data type. expression2
- An expression that returns a value of any built-in numeric data type.
If either argument is decimal floating-point, the result is DECFLOAT(34); otherwise, the result is a double-precision floating-point number. The result can be null. When not null, the result is between -1 and 1.
The function is applied to the set of (expression1, expression2) pairs derived from the argument values by the elimination of all pairs for which either expression1 or expression2 is null.
COVARIANCE(expression1,expression2)/
(STDDEV(expression1)*
STDDEV(expression2))
The order in which the values are aggregated is undefined, but every intermediate result must be within the range of the result data type.
CORR can be specified in place of CORRELATION.
Example
SELECT CORRELATION(SALARY, BONUS)
INTO :CORRLN
FROM EMPLOYEE
WHERE WORKDEPT = 'A00'
CORRLN is set to approximately 9.99853953399538E-001 when using the sample table.