I have seen similar behavior in MySQL, but not this exact case (or at least I can't find the bug if it exists).
A similar bug is: http://bugs.mysql.com/bug.php?id=48916 - Server incorrectly processing HAVING clauses with an ORDER BY clause
It was a similar situation - the addition of the ORDER BY produced result sets for a HAVING clause that should have had 0 rows.
I have seen similar behavior in MySQL, but not this exact case (or at least I can't find the bug if it exists).
A similar bug is: bugs.mysql. com/bug. php?id= 48916 - Server incorrectly processing HAVING clauses with an ORDER BY clause
http://
It was a similar situation - the addition of the ORDER BY produced result sets for a HAVING clause that should have had 0 rows.