Analytic function and select specific row
问题 I have a table Tdate Name value 20130101 xxx 1.2 20130102 xxx 1.4 ... 20130101 yyy 1.3 20130102 yyy 2.3 I want to calculate the value correlation between each name in Jan 2013, and list top 20 of them. Here is my code: With targetRow as ( Select XXX Where tDate is “20130131”) Select a.name, b.name, corr(a.value,b.value) over (partition by name Range between 31 preceding and targetRow) Correlation From logprofittest a, logprofittest b Order by correlation Here are questions: (1) How to