corr() function

The corr() aggregate function returns a coefficient of correlation between two numbers.

Syntax

The corr() function has the following syntax:
double = corr(Set(double) inputa, Set(double) inputb);

The inputa value specifies the first number in the set.

The inputb value specifies the next number in the set.

Returns

The function returns the coefficient of correlation between two numbers.

Example

For example, assume that the function_t table contains the following values:

 col1 | col2 
------+------
  1.2 |  1.4
  1.4 |  1.6
  1.6 |  1.8
The following query returns the correlation coefficient for the values in the table:
select corr(col1,col2)from function_t;
 corr 
------
    1
(1 row)