title: SQL filtering by Average
body: <p>i have two tables products and reviews<br>
  each product has several reviews linked by a foreign-key product_id in the reviews table<br>
  additionally each review has a field called rating with a decimal value<br>
  i wish to get the names of all products whose average rating is above a certain threshold<br>
  something in the lines of </p>
  
  <pre><code>SELECT p.name
  FROM products p
  INNER JOIN reviews r ON p.id = r.product_id
  WHERE avg(r.rating) &gt; 3
  </code></pre>
  
  <p>MySQL is not letting me use the avg function in the where clause.<br>
  How do I do something like this?</p>