Using an aggregate function in where
You can't use aggregate expression in the where
clause - this is what the having
clause is for:
SELECT a, SUM(b)
FROM foo
GROUP BY a
HAVING SUM(b) > 9
You can't use aggregate expression in the where
clause - this is what the having
clause is for:
SELECT a, SUM(b)
FROM foo
GROUP BY a
HAVING SUM(b) > 9