Cannot GROUP by aggregate field (Error 1846)

You have attempted to use an aggregate function (MIN( ), MAX( ), SUM( ), AVG( ), COUNT( ), NPV( ), STD( ) or VAR( )) in a GROUP clause.