Skip to main content

Overview

The CORR() aggregate function calculates the Pearson correlation coefficient between two sets of number pairs. This function measures the linear relationship between two variables, providing a value between -1 and 1.

Syntax

The syntax for this function is as follows:

Parameters

  • y: variable being predicted
  • x: variable used for prediction

Example

For the needs of this section, we are going to use a simplified version of the film table from the Pagila database, containing only the title, length and rating columns. The complete schema for the film table can be found on the Pagila database website.
The query below uses the CORR() function to calculate the correlation between film length and rating:
By running the query above we will get the following output: