title: difference between where and having with respect to aliases
body: <p>If I create an alias in the <code>select</code> clause then I cannot use it in the <code>where</code> clause because according to the order of execution of sql queries <code>where</code> comes before <code>select</code>.</p>
  
  <p>But I can create an alias in the <code>select</code> clause and use it in a <code>having</code> clause though <code>having</code> comes before <code>select</code>. </p>
  
  <p>Why is it so?</p>
  
  <p>Ex:</p>
  
  <pre><code>select type, (case when number&gt;25 then 1 else 0 end) inc 
  from animals
  where inc='1';
  </code></pre>
  
  <p>this wont work. But,</p>
  
  <pre><code>select type, (case when number&gt;25 then 1 else 0 end) inc 
  from animals
  having inc='1'; 
  </code></pre>
  
  <p>This works. Why so?</p>