DB2 SQL-Error: -120
SQLState: 42903
Short Description: AN AGGREGATE FUNCTION IS NOT VALID IN THE CONTEXT IN WHICH IT WAS INVOKED
An aggregate function or a user-defined function that is sourced on an aggregate function is not permitted in a SET clause, VALUES clause, SET host-variable statement, SET transition-variable statement, assignment statement, or as the expression of a RETURN statement. An aggregate function or a user-defined function that is sourced on an aggregate function is allowed in a WHERE clause only if the WHERE clause appears within a subquery of a HAVING clause. System action: The statement cannot be executed. Programmer response: The implied function is not supported by DB2. Refer to Chapter 4 of DB2 SQL Reference for information about restrictions on operands that can be specified within a WHERE clause, SET clause, VALUES clause, SET host-variable statement, SET transition-variable statement, assignment statement, or as the expression of a RETURN statement.