The WHERE filter usually follows a link name to select related objects connected via that link. However, a link path can begin when a WHERE filter, in which case it selects perspective objects. For example:GET /Email/Person/_aggregate?range=0&m=COUNT(*)&f=WHERE(Department:sales).OfficeIn this query, the grouping field is Office. But because it is prefixed with a WHERE filter, the filter is applied to perspective objects (Person). Following an outer WHERE filter, the scope of the link path remains at the query perspective, consequently the subsequent link path or additional WHERE filters must be applicable to the query perspective.When the grouping field is used with a grouping function such as BATCH, TERMS, or TOP, the outer WHERE field is always specified as a prefix to the grouping field. Examples:GET /Email/Person/_aggregate?range=0&m=COUNT(*)&f=TOP(6,WHERE(Department:sales).Office)GET /Email/Message/_aggregate?range=0&m=COUNT(*)
&f=BATCH(WHERE(Tags=AfterHours).Size,1000,10000,100000)GET /Email/Message/_aggregate?range=0&m=COUNT(*)&f=TOP(5,TERMS(WHERE(Size>100000).Subject))GET /Email/Message/_aggregate?range=0&m=COUNT(*)
&f=TERMS(WHERE(Size>100000).Subject),WHERE(Sender.Person.LastName:Cuthill).TagsIf present, the query parameter (&q) is used first to select objects, the total number of which is reflected in the <totalobjects> element in the query results. Each outer WHERE function is used to further filter objects passed to the calculations of the corresponding aggregate groups.