The Salesforce documentation is notably terse in describing Considerations When Using
GROUP BY. The guidance provided for determining which fields can be grouped is simply:
The Field object associated with DescribeSObjectResult has a groupable field that defines whether you can include the field in a GROUP BY clause.
Further, the document states that
You can't use child relationship expressions that use the __r syntax in a query that uses a GROUP BY clause.
Failure to use a properly groupable field yields the error
field 'FIELD_NAME__c' can not be grouped in a query call