-120 AN AGGREGATE FUNCTION OR OLAP SPECIFICATION IS NOT VALID IN THE CONTEXT IN WHICH IT WAS INVOKED
Explanation
An aggregate function, a user-defined function that is sourced on an aggregate function, or an OLAP specification is not permitted in the following contexts:
- In a SET clause.
- In a VALUES clause.
- In a SET transition-variable statement.
- In an assignment statement.
- In the key-expression of an index definition.
- In the expression of a RETURN statement.
An aggregate function or an OLAP specification can only be specified in a WHERE clause if the WHERE clause appears within a subquery of a HAVING clause.
The search-condition of the ON clause of a MERGE statement cannot contain an expression that uses an aggregate function.
System action
The statement cannot be processed.
Programmer response
Change the statement so that the aggregate function or OLAP specification is not specified in a context where it is not allowed.
SQLSTATE
42903