title: PostgreSQL: Using subquery abbreviation ('AS') in the WHERE clause
body: <p>Consider the following query in PostgreSQL:</p>
  
  <pre><code>SELECT 
      a, b, 
     (A VERY LONG AND COMPLICATED SUBQUERY) AS c,
     (ANOTHER VERY LONG AND COMPLICATED SUBQUERY) AS d
  FROM table
  </code></pre>
  
  <p>I want to have <code>c</code> and <code>d</code> in the <code>WHERE</code> clause, like:</p>
  
  <pre><code>WHERE c AND d;
  </code></pre>
  
  <p>But, as far as I know, I can only do:</p>
  
  <pre><code>WHERE A VERY LONG AND COMPLICATED SUBQUERY) AND 
     (ANOTHER VERY LONG AND COMPLICATED SUBQUERY)
  </code></pre>
  
  <p>Which is clumsy, code-replicating, <a href="http://en.wikipedia.org/wiki/Single_choice_principle" rel="noreferrer">breaking the single-choice principle</a> and utterly ugly.</p>
  
  <p>By the way, the same problem applies to the <code>SELECT</code> clause: I can not use abbreviations for previously-defined subqueries.</p>