title: How to use WHERE for custom field (alias)?
body: <p>How do I accomplish query like so:</p>
  
  <pre><code>SELECT type, COUNT(name) as cnt FROM products WHERE cnt &gt; 1 GROUP BY type
  </code></pre>
  
  <p>That query produces error <code>#1054 - Unknown column 'cnt' in 'where clause'</code></p>
  
  <p>It's because <code>WHERE</code> applies before grouping.<br>
  How can I workaround this?</p>
  
  <p>Table structure:</p>
  
  <pre><code>id      name                type        price
  123451  Park's Great Hits   Music       19.99
  123452  Silly Puddy         Toy         3.99
  123453  Playstation         Toy         89.95
  123454  Men's T-Shirt       Clothing    32.50
  123455  Blouse              Clothing    34.97
  123456  Electronica 2002    Music       3.99
  123457  Country Tunes       Music       21.55
  123458  Watermelon          Food        8.73
  </code></pre>
  
  <p>Table structure borrowed from <a href="http://www.tizag.com/mysqlTutorial/mysqlcount.php" rel="nofollow">http://www.tizag.com/mysqlTutorial/mysqlcount.php</a> for simplicity.</p>