DB2 SQL-Error: -133
Short Description: AN AGGREGATE FUNCTION IN A SUBQUERY OF A HAVING CLAUSE IS INVALID BECAUSE ALL COLUMN REFERENCES IN ITS ARGUMENT ARE NOT CORRELATED TO THE GROUP BY RESULT THAT THE HAVING CLAUSE IS APPLIED TO
If an aggregate function has a correlated column reference, it must be correlated from within a HAVING clause to the GROUP BY result that the HAVING clause is applied to. All column references in the argument must satisfy this condition. System action: The statement cannot be executed. Programmer response: Refer to Chapter 4 of DB2 SQL Reference for information about restrictions on the syntax of the HAVING clause.