title: Error Code 1111. Invalid use of group function
body: <p>So this works:</p>
  
  <pre><code>SELECT c.name AS country_name, c.population AS country_population, SUM(ci.population) AS city_population, ROUND(100*(SUM(ci.population)/c.population)) AS city_population_percent
  FROM country AS c
  JOIN city AS ci
  ON c.code = ci.countrycode
  WHERE c.continent = 'Europe'
  GROUP BY c.name
  </code></pre>
  
  <p>But I need to only grab the city_population_percent values greater than 30, so I try this:</p>
  
  <pre><code>SELECT c.name AS country_name, c.population AS country_population, SUM(ci.population) AS city_population, ROUND(100*(SUM(ci.population)/c.population)) AS city_population_percent
  FROM country AS c
  JOIN city AS ci
  ON c.code = ci.countrycode
  WHERE c.continent = 'Europe'
  **AND ROUND(100*(SUM(ci.population)/c.population)) &gt; 30**
  GROUP BY c.name
  </code></pre>
  
  <p>And that's when I get:</p>
  
  <blockquote>
    <p>Error Code 1111. Invalid use of group function</p>
  </blockquote>
  
  <p>That is, it fails when I add this condition in the <code>WHERE</code>:</p>
  
  <pre><code>AND ROUND(100*(SUM(ci.population)/c.population)) &gt; 30
  </code></pre>