OLAP Aggregate Queries : Grouping Parameter : Grouping Field Aliases

Grouping Field Aliases
By default, aggregate query group results use the fully-qualified path name of each grouping field. You can shorten the output result by using an alias for each grouping field. The alias name is used instead of the fully-qualified name. For example:
GET /Email/Message/_aggregate?m=COUNT(*)&f=TOP(3,Sender.Person.Name)&range=0
This query produces a result such as the following:
<results>
<aggregate metric="COUNT(*)" group="TOP(3,Sender.Person.Name)"/>
<totalobjects>6030</totalobjects>
<summary>6030</summary>
<totalgroups>186</totalgroups>
<groups>
<group>
<metric>5256</metric>
<field name="Sender.Person.Name">(null)</field>
</group>
<group>
<metric>82</metric>
<field name="Sender.Person.Name">Quest Support</field>
</group>
<group>
<metric>80</metric>
<field name="Sender.Person.Name">spb_setupbuilder</field>
</group>
</groups>
</results>
The fully-qualified field name Sender.Person.Name is used for the field parameter in each group element. An alias can be substituted for a grouping field by appending AS name or .AS(name) to the grouping field. The two syntaxes are equivalent. The AS function’s parameter can be an unquoted term or a quoted string. Example:
GET /Email/Message/_aggregate?m=COUNT(*)&f=TOP(3,Sender.Person.Name) AS Name&range=0
GET /Email/Message/_aggregate?m=COUNT(*)&f=TOP(3,Sender.Person.Name).AS(Name)&range=0
With either form, the alias Name is used in the output as shown below:
<results>
<aggregate metric="COUNT(*)" group="TOP(3,Sender.Person.Name)"/>
<totalobjects>6030</totalobjects>
<summary>6030</summary>
<totalgroups>186</totalgroups>
<groups>
<group>
<metric>5256</metric>
<field name="Name">(null)</field>
</group>
<group>
<metric>82</metric>
<field name="Name">Quest Support</field>
</group>
<group>
<metric>80</metric>
<field name="Name">spb_setupbuilder</field>
</group>
</groups>
</results>
When many groups are returned and/or the grouping field name is long, the alias name can significantly shorten the output results. An alias name can also improve the identity of the groups.