Corr Function

The corr function returns the Pearson correlation coefficient.

formula

The syntax of the corr function is

corr(x,y [,w])

x and y are the values for which the correlation shall be calculated.
If x or y is null, the value pair is ignored.
If the number of value pairs is zero, the function returns null.
If the variance of x or y is zero, the function returns null.
w are the weights. If no value is provided the weight is assumed to be 1.

Example

SELECT country, corr(sales, price)
  FROM sales
  GROUP BY country;