The documentation on DescribeFieldResult
is pretty clear. If this method returns true
, you can use it in a GROUP BY
clause.
isGroupable()
Returns true if the field can be included in the GROUP BY clause of a SOQL query, false otherwise. This method is only available for Apex classes and triggers saved using API version 18.0 and higher.
I have to dig for better documentation, but I know specifically that formula fields as well as boolean and rich text fields are not groupable.