title: Using an Alias in PostgreSQL query returns "column does not exist"
body: <p>I'm trying to get the result of a calculated column in PostgreSQL using aliases from other select queries. I want to divide totalScore by totalEmployee to get the average for the section. But when I try to perform the calculation I get an error.</p>
  
  <pre><code>SELECT
      cast( sum( empskills.score ) as dec( 2 , 1 ) ) AS totalScore,
      skills.skill_name,  
      (SELECT
          count(employees.first_name)
          FROM
          sections
          INNER JOIN employees
          ON sections.id = employees.section_id
          WHERE
          sections.id = 2) as totalEmployees,
      (SELECT totalScore / totalEmployees) as finalResult
  FROM
      employees
      INNER JOIN empskills
       ON employees.id = empskills.empid
      INNER JOIN skills
       ON empskills.skillid = skills.id
      INNER JOIN sections
       ON employees.section_id = sections.id
  WHERE
      sections.id = 2
  GROUP BY
      skills.skill_name
  </code></pre>
  
  <pre><code>ERROR:  column "totalscore" does not exist
  LINE 17:  (SELECT totalScore / totalEmployees)
  </code></pre>
  
  <p>I expected to have the results of the division equation.</p>