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?
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)>10) GROUP by res_id
Every column in your select with group by must be either aggregated on, or included in group by. Conditions on aggregated expressions must appear in the having clause, like this: