sql - What I am doing wrong in this correlation query in oracle SqlDevelopper -


i'm trying build query select correlation coefficient determine rated movie user

the structure of table this:

enter image description here

my query this:

select       user1, user2,     ((psum - (sum1 * sum2 / n)) / sqrt((sum1sq - pow(sum1, 2.0) / n) * (sum2sq - pow(sum2, 2.0) / n))) r,     n     (select           n1.idclient user1,          n2.idclient user2,          sum(n1.cote) sum1,          sum(n2.cote) sum2,          sum(n1.cote * n1.cote) sum1sq,          sum(n2.cote * n2.cote) sum2sq,          sum(n1.cote * n2.cote) psum,          count(*) n               cote n1 // <---------- editor pointing missing parenthese here red line      left join         cote n2 on n1.idfilm = n2.idfilm                n1.idclient > n2.idclient     group         n1.idclient, n2.idclient) step1 order     r desc, n desc 

but i'm confident haven't miss parentheses, did wrong?

p.s : i'm not expert , understand

oracle doesn't let use as table aliases, column aliases. the select-list syntax shows optional as; the table-reference syntax not.

in line highlighted

from cote n1 

the as being treated table alias (although it's reserved word can't use alias); sees n1 , doesn't know means. parser seems fall guessing open parentheses should have been closed, before n1 token in case, have completed had parsed far (i'm simplifying, of course); hence not entirely helpful error message.

so need remove as 3 places you're using it:

select           user1, user2,         ((psum - (sum1 * sum2 / n)) / sqrt((sum1sq - pow(sum1, 2.0) / n) * (sum2sq - pow(sum2, 2.0) / n))) r,         n         (select                  n1.idclient user1,                 n2.idclient user2,                 sum(n1.cote) sum1,                 sum(n2.cote) sum2,                 sum(n1.cote * n1.cote) sum1sq,                 sum(n2.cote * n2.cote) sum2sq,                 sum(n1.cote * n2.cote) psum,                 count(*) n                         cote n1     left join         cote n2     on         n1.idfilm = n2.idfilm                            n1.idclient > n2.idclient     group         n1.idclient, n2.idclient) step1 order         r desc,         n desc 

Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -