Oracle Error ORA-36164: (XSMXAGGR07) When using the COUNTVAR clause, the number of variables to be aggregated (number) must match the number of COUNTVAR variables (number).

Oracle Error Message

ORA-36164: (XSMXAGGR07) When using the COUNTVAR clause, the number of variables to be aggregated (number) must match the number of COUNTVAR variables (number).

Reason for the Error

The user specified a COUNTVAR clause to the AGGREGATE command, but the number of COUNTVAR variables specified did not match the number of variables to be aggregated

Solution

Specify a separate COUNTVAR for each variable