From the course: SQL for Statistics Essential Training

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Correlations between variables

Correlations between variables - PostgreSQL Tutorial

From the course: SQL for Statistics Essential Training

Start my 1-month free trial

Correlations between variables

- [Narrator] Let's look at the correlation function. It takes two columns and returns a measure of how well the two variables are correlated. If they always increase in value, then the correlation coefficient will be one. If one rises as the other falls, then the correlation will be negative. In our example dataset, the value of the revenue is a multiple of units sold. So these two variables are highly correlated. So let's query about that. Let's SELECT. The correlation function is C-O-R-R, and then we specify the two columns we're interested in, in this case, it's units_sold and revenue. And these are both from the store_sales table. As expected, the correlation between units_sold and revenue is one. We might think that we sell more units when there are more employees working on a shift. Let's test that hypothesis. Let's select the correlation between units_sold and employee_shifts. Here, the correlation is about 0.54. So there is some positive correlation, but it's not always the…

Contents