2212 Aggregate cannot be nested

Advantage Error Guide

Problem: The expression for an aggregate function (MIN, MAX, SUM, AVG or COUNT) contains another aggregate function. For example: SUM( MIN( id )).

Solution: The nested aggregate is not a valid SQL expression.