title: postgresql corr aggregate function returning null
body: <p>I have two perfectly (or completely imperfectly?) correlated numbers, and i want to find correlation between them. The original scenario is different and more complex, but the problem is somewhere within the method of correlation pg uses. Please consider the following query:</p>
  
  <pre><code>    WITH all_series AS (
        select t as id, 'One' as name, 1 as num from generate_series(1, 10) t
        UNION
        select t as id, 'Two' as name, 2 as num from generate_series(1, 10) t
        ORDER BY name, id
      )
  
      SELECT (t1.name || '|' || t2.name) as names, corr(t2.num, t1.num) c
      FROM all_series t1
      INNER JOIN all_series t2 ON t1.id = t2.id
      WHERE t1.name &gt; t2.name
      GROUP BY (t1.name || '|' || t2.name)
      ORDER BY (t1.name || '|' || t2.name)
  </code></pre>
  
  <p>If you remove the Group and open selects, the numbers are perfectly aligned, which should give SOMETHING as correlation..  but it gives empty (not even zero).</p>
  
  <p>regards,</p>