aggregate functions are not allowed in the group by clause code example
Example: aggregate functions are not allowed in WHERE
Try using the condition inside the "Having" clause
Try using the condition inside the "Having" clause