title: Invalid use of group function - MySQL
body: <p>This error occurs while I run the select query, please advise.</p>
  
  <pre><code>Error No : 1111
  Error : Invalid use of group function
  </code></pre>
  
  <p>Query: </p>
  
  <pre><code>SELECT cm.contactid, cm.firstname, cm.surname, cm.mobile, COUNT( * ) total
  FROM sales_master as sm, contact_master as cm
  WHERE sm.contactid = cm.contactid 
  AND cm.mobile != '' AND orderdate&gt;='2012-12-18' AND orderdate&lt;='2013-03-18' 
  GROUP BY sm.contactid 
  HAVING COUNT(*) &gt;= 1 
  ORDER BY COUNT(*) DESC, cm.firstname ASC
  </code></pre>