Invalid use of an aggregate function

Item Value
SQLCODE -150
Constant SQLE_AGGREGATES_NOT_ALLOWED
SQLSTATE 42W06
Sybase error code 13204
ODBC 2 State 37000
ODBC 3 State 42000

Probable cause 

You attempted to use an aggregate function inappropriately. For example, a SELECT statement cannot contain an aggregate function within a predicate in the WHERE clause unless the aggregate function constitutes an outer reference. Other invalid uses include specifying an aggregate function in the SET clause of an UPDATE statement, or using an aggregate function in a CHECK constraint.