ORA-00978
nested group function without GROUP BY
Cause
A group function, such as AVG, COUNT, MAX, MIN, SUM, STDDEV, or VARIANCE, was used within another group function, as in MAX(COUNT(*)), without a corresponding GROUP BY clause.
Action
Either add a GROUP BY clause or remove the extra level of nesting.