If a query selects an aggregate function, any field appearing outside the aggregate function in the SELECT clause must also appear in the GROUP BY clause of the query. This is a common cause of confusion; although users may think they do not want to group a result by a particular column, they often find that adding the column name to the end of the GROUP BY clause yields the desired result.