When IFNULL is used in GROUPBY, Unknown column error is thrown when trying to use it in HAVING....
CREATE TABLE aaaa (a INT, b INT, c int);
SELECT 0 FROM aaaa GROUP BY IFNULL(a,b) HAVING IFNULL( aaaa.a, aaaa.b)<>SUM( IFNULL( aaaa.c, 0));
Result: Error - Unknown column 'aaaa.a' in 'having clause'
Strange is that when SELECT * is used works ok...