title: Syntax error with aliases in PostgreSQL subqueries
body: <p>I'm new to SQL and trying to do a certain query in which I need two subqueries. I have to give them aliases, but when I do it says:</p>
  
  <pre><code>ERROR:  syntax error at or near "as"
  </code></pre>
  
  <p>But I don't see anything wrong in the syntax. I'm having a lot of trouble with this kind of queries and I don't find much information or examples. Would you help me?</p>
  
  <pre><code>Select
      ...
  from
      turno,
      (select * from
          (
              select 
                  ...
               from 
                  accion
              where
                  accion.tipo = 4 or accion.tipo = 5
          ) as part1
          union
          (
              select 
                  ...
               from 
                  accion
              where
                  accion.tipo &lt;&gt; 4 and accion.tipo &lt;&gt; 5
          ) as part2
      ) as accion
  where 
      ...
  ;
  </code></pre>
  
  <p>Thanks a lot.</p>