title: Accessing column alias in postgresql
body: <p>Having a little bit of trouble understanding how a query alias works in postgresql.
  I have the following:</p>
  
  <pre><code>SELECT DISTINCT robber.robberid,
                  nickname,
                  Count(accomplices.robberid) AS count1
  FROM   robber
         INNER JOIN accomplices
                 ON accomplices.robberid = robber.robberid
  GROUP  BY robber.robberid,
            robber.nickname
  ORDER  BY Count(accomplices.robberid) DESC;
  
  
   robberid |            nickname            | count1 
  ----------+--------------------------------+--------
         14 | Boo Boo Hoff                   |      7
         15 | King Solomon                   |      7
         16 | Bugsy Siegel                   |      7
         23 | Sonny Genovese                 |      6
          1 | Al Capone                      |      5
   ...
  </code></pre>
  
  <p>I can rename the "count1" column using the as command but I can't seem to be able to refer to this again in the query? I am trying to include a HAVING command at the end of this query to query only objects who have a count less than half of the max.</p>
  
  <p>This is homework but I am not asking for the answer only a pointer to how I can include the count1 column in another clause.</p>
  
  <p>Can anyone help?</p>