'Oracle SQL CORR function
I have a small project for school but I am struggling to get past one part of it. I have two columns so my table would look like the below example. My objective is to try to use some sort of function within Oracle SQL Developer to determine if there is a correlation between the two data sets. I was considering using the CORR function but I don't think that would work as there are too many unique runtimes. Any thoughts are appreciated.
| Runtime | Rating |
|---|---|
| 321 | 9.5 |
| 238 | 9.9 |
| 228 | 9.1 |
| 225 | 8.5 |
| 221 | 8.3 |
Solution 1:[1]
Creating a small table for testing, using your values:
create table t (runtime, rating) as
select 321, 9.5 from dual union all
select 238, 9.9 from dual union all
select 228, 9.1 from dual union all
select 225, 8.5 from dual union all
select 221, 8.3 from dual
;
The query and result look like this:
select round(corr(runtime, rating), 2) as correl from t;
CORREL
----------
.5
The correlation coefficient is 0.5. The two quantities are positively correlated, 0.5 is significant; but they are not perfectly (or even "almost perfectly") correlated: the correlation coefficient is not close to 1.
In any case, any further interpretation of the result (either on this small test or on your actual, real-life data) is in the field of statistics - it has nothing to do with programming.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | mathguy |
