SQL SELECT products WHERE 'average price per product' < value
<p>I'd like to only return prod_id's that have an average price &lt; 7. Looking at the sample below, the query should only return prod_id 1 (average price = 5)</p>

<pre><code>+---------+-------+
| prod_id | price | 
+---------+-------+
| 1       | 3     |
| 1       | 4     |
| 1       | 8     |
| 2       | 12    |
| 2       | 14    |
+---------+-------| 
</code></pre>

<p>So the desired results should be:</p>

<pre><code>+---------+-------+
| prod_id | avg_pr| 
+---------+-------+
| 1       | 5     |
+---------+-------| 
</code></pre>

<p>I tried this:</p>

<pre><code>SELECT prod_id, AVG(price) 
FROM products
WHERE AVG(price) &lt; 7
GROUP BY prod_id
</code></pre>

<p>It's giving me this error: #1111 - Invalid use of group function</p>