The aggregate expression '%1' must appear in either the SELECT list or a HAVING clause subquery

Error constant SQLE_INVALID_AGGREGATE_PLACEMENT
ODBC 2 state 37000
ODBC 3 state 42000
Parameter 1 The aggregated expression in error.
Severity 15
SQLCODE -862
SQLSTATE 42W69
Sybase error code 13866
 Probable cause