-8017: Column must be group column

Explanation:

A column which is not a group column, i.e., which is not contained in the GROUP clause, was specified in a selected column or in the HAVING clause. Columns that are not group columns can only occur in arguments of the AVG, COUNT, MAX, MIN, STDDEV, SUM and VARIANCE set functions.

User Action:

Insert the specified column into the group clause as a further group column, or remove it from the selected column or HAVING clause.