Oracle SQL - CORR_K function

Introduction

CORR_K function calculates a rank correlation.

It is a non-parametric procedure. The following options are available for the CORR_K function.

For the coefficient:

CORR_K(expr1, expr2, 'COEFFICIENT') 

For significance level of one-sided test:

CORR_K(expr1, expr2, 'ONE_SIDED_SIG') 

For significance level of two-sided test:

CORR_K(expr1, expr2, 'TWO_SIDED_SIG') 

Given the following table.

Demo

SQL>
SQL> drop table my_table;

Table dropped.-- w  w w  .  jav  a  2s  .c  o  m

SQL> create table my_table(
  2  x      NUMBER(4)  primary key,
  3  y      NUMBER(4)  not null);
SQL>
SQL> insert into my_table values(1,2);
SQL> insert into my_table values(2,4);
SQL> insert into my_table values(3,6);
SQL> insert into my_table values(4,9);
SQL> insert into my_table values(5,13);
SQL> insert into my_table values(6,16);
SQL> insert into my_table values(7,20);
SQL> insert into my_table values(8,27);
SQL> insert into my_table values(9,32);
SQL> insert into my_table values(10,47);
SQL> insert into my_table values(11,53);
SQL> insert into my_table values(12,60);
SQL> insert into my_table values(13,76);
SQL> insert into my_table values(14,100);
SQL> insert into my_table values(15,130);
SQL> insert into my_table values(16,189);
SQL> insert into my_table values(17,300);
SQL> insert into my_table values(18,789);
SQL> insert into my_table values(19,1000);
SQL>

Demo

SQL>
SQL> select CORR_K(y, x, 'COEFFICIENT') from my_table;
SQL> select CORR_K(y, x, 'ONE_SIDED_SIG') from my_table;
SQL> select CORR_K(y, x, 'TWO_SIDED_SIG') from my_table;
SQL>--  ww  w  . j  a va  2 s.  c  o  m