I am having issues with a FetchXML query running against Dynamics CRM 2013 (online).
When running this simple query
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false" count="5">
<entity name="activitypointer">
<attribute name="activityid" alias="activity_id" />
<attribute name="activitytypecode" alias="activity_type" />
<attribute name="ownerid" alias="owner" />
</entity>
</fetch>
I get the expected results for the activity_type column e.g. "email", "opportunityclose" etc.
But when I attempt this aggregate version of the same query
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false" aggregate="true">
<entity name="activitypointer">
<attribute name="activityid" alias="activity_count" aggregate="count" />
<attribute name="activitytypecode" alias="activity_type" groupby="true" />
<attribute name="ownerid" alias="owner" groupby="true" />
</entity>
</fetch>
I get the correct results for the activity_count and owner columns, but the "activity_type" column is populated with just "Microsoft.Xrm.Sdk.OptionSetValue" or if ran within a report "#error".
I have also tried adding not-null filters to all fields to ensure that null values are not causing and issue but this makes no difference.
The issue also occurs if the query is run in the Query Designer, which rules out the report config as far as I can tell.

I assume this is something to do with grouping by an option field type.
Does anyone know how to resolve this issue?