Results 1 to 2 of 2
  1. #1
    Join Date
    May 2007
    Posts
    3

    Unanswered: Finding correlation using derived columns?

    I want to use the aggregate CORR_S function which take two numerical columns and output the correlation between them. Assuming I have the table:

    Employee(name, gender, salary) where I want to create two derived columns, how would I do it?

    Like,
    -------------------
    SELECT CORR_S(
    SELECT salary
    FROM employees
    WHERE salary < 10000,
    SELECT salary
    FROM employees
    WHERE salary > 10000
    ) as correlation
    FROM employees
    ---------------------

    It will find the correlation between salary's less than $10,000 in one column and salary's more than $10,000 in another column. Of course, I get an error when running the query. It's no problem if I use CORR_S(salary, salary) but I want to use derived columns, is it possible? Or, will I need to create a new table view with two new columns CORR_S(lowSalary, highSalary)?

    Thanks.

  2. #2
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    Well, a VIEW was my first thought too.

    However, you might try something like this:
    Code:
    SELECT corr_s (x.salary, y.salary) 
    FROM (SELECT salary FROM EMPLOYEES 
          WHERE salary < 10000) x,
         (SELECT salary FROM EMPLOYEES
          WHERE salary > 10000) y;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •