I understand that AGGR function will work like a group by function in SQL. The output of Aggr(Count( DISTINCT ProductCode), ProductCode, Division) will be the count of productcode grouped by productcode and Division.
This expression does not make sense. The Count() will be one for every ProductCode/Division combination (and the DISTINCT will do nothing since you are already distinct because of the Aggr() dimensions). You cannot do this expression directly in SQL as SQL will not allow you to aggregate and group by the same field. The nearest I could get was
Group By ProductCode, Division;
Logic will get you from a to b. Imagination will take you everywhere. - A Einstein