title: postgres column alias problem
body: <p>As a newbie to Postgresql (I'm moving over because I'm moving my site to heroku who only support it, I'm having to refactor some of my queries and code. Here's a problem that I can't quite understand the problem with:</p>
  
  <pre><code>PGError: ERROR:  column "l_user_id" does not exist
  LINE 1: ...t_id where l.user_id = 8 order by l2.geopoint_id, l_user_id ...
                                                               ^
  </code></pre>
  
  <p>...query:</p>
  
  <pre><code>   select distinct 
            l2.*, 
            l.user_id as l_user_id, 
            l.geopoint_id as l_geopoint_id 
       from locations l 
  left join locations l2 on l.geopoint_id = l2.geopoint_id 
      where l.user_id = 8 
   order by l2.geopoint_id, l_user_id = l2.user_id desc
  </code></pre>
  
  <p>clause "l.user_id as l_user_id, l.geopoint_id as l_geopoint_id" was added because apparently postgres doesn't like order clauses with fields not selected. But the error I now get makes it look like I'm also not getting aliasing. Anybody with postgres experience see the problem?</p>
  
  <p>I'm likely to have a bunch of these problems -- the queries worked fine in mySql...</p>