OLAP Aggregate Queries : Grouping Parameter : Single-level Grouping

Single-level Grouping
When the grouping parameter consists of a single grouping field, objects are divided into sets based on the distinct values found for the grouping field. A separate metric value is computed for each group. For example, this aggregate query uses a single-valued scalar as the grouping field:
GET /Email/Message/_aggregate?m=MAX(Size)&f=Tags&range=0
The Tags field logically partitions objects into groups: one for each field value. Each object is included in each group for which is has a Tags value. If an object has no Tags value, it is placed in a (null) group. The maximum Size is then computed for each group. A typical result in XML is shown below:
<results>
<aggregate metric="MAX(Size)" group="Tags"/>
<totalobjects>6030</totalobjects>
<summary>16796009</summary>
<groups>
<group>
<metric>4875</metric>
<field name="Tags">(null)</field>
</group>
<group>
<metric>16796009</metric>
<field name="Tags">AfterHours</field>
</group>
<group>
<metric>16796009</metric>
<field name="Tags">Customer</field>
</group>
</groups>
</results>
In JSON:
{"results": {
"aggregate": {"metric": "MAX(Size)", "group": "Tags"},
"totalobjects": "6030",
"summary": "16796009",
"groups": [
{"group": {
"metric": "4875",
"field": {"Tags": "(null)"}
}},
{"group": {
"metric": "16796009",
"field": {"Tags": "AfterHours"}
}},
{"group": {
"metric": "16796009",
"field": {"Tags":"Customer"}
}}
]
}}
For grouped aggregate queries, the results element contains a groups element, which contains one group for each group value. Each group contains the field name and value for that group and the corresponding metric value. The totalobjects value computes the number of objects selected in the computation. The summary value computes the metric value across all selected objects independent of groups. For the AVERAGE function, this provides the true average, not the average of averages.