title: Why can't I use column aliases in the next SELECT expression?
body: <p>Can I modify the next to use the column aliases <code>avg_time</code> and <code>cnt</code> in an expression <code>ROUND(avg_time * cnt, 2)</code>?</p>
  
  <pre><code>SELECT 
      COALESCE(ROUND(stddev_samp(time), 2), 0) as stddev_time, 
      MAX(time) as max_time, 
      ROUND(AVG(time), 2) as avg_time, 
      MIN(time) as min_time, 
      COUNT(path) as cnt, 
      ROUND(avg_time * cnt, 2) as slowdown, path
  FROM 
      loadtime
  GROUP BY
      path
  ORDER BY
      avg_time DESC
  LIMIT 10;
  </code></pre>
  
  <p><strong>It raises the next error:</strong></p>
  
  <pre><code>ERROR:  column "avg_time" does not exist
  LINE 7:  ROUND(avg_time * cnt, 2) as slowdown, path
  </code></pre>
  
  <p><strong>The next, however, works fine</strong> (use primary expressions instead of column aliases:</p>
  
  <pre><code>SELECT 
      COALESCE(ROUND(stddev_samp(time), 2), 0) as stddev_time, 
      MAX(time) as max_time, 
      ROUND(AVG(time), 2) as avg_time, 
      MIN(time) as min_time, 
      COUNT(path) as cnt, 
      ROUND(AVG(time) * COUNT(path), 2) as slowdown, path
  FROM 
      loadtime
  GROUP BY
      path
  ORDER BY
      avg_time DESC
  LIMIT 10;
  </code></pre>