title: Outlier query with mysql using group by
body: <p>I use the query below to detect a 10 centimeter difference between the average snowlevel and the minimum snowlevel. But PhpMyadmin says it is an invalid use of the group function. Can't see what is wrong. Do you know it?</p>
  
  <pre><code>SELECT lud, res_id, resort, 
  MIN(snow_valley) as snow_val_min, 
  MAX(snow_valley) as snow_val_max,
  ROUND(AVG(snow_mountain),0) as snow_mnt_avg, 
  MIN(snow_mountain) as snow_mnt_min
  from sv_condition_sw 
  where (lud ='2011-12-31')  AND (AVG(snow_mountain)-MIN(snow_mountain)&gt;10) GROUP by res_id
  </code></pre>