So I want to get the top 3 of the sum of values grouped by personid. So how do I set up the xml to support the nested aggregate?
<fetch top="50" aggregate="true" >
<entity name="elcn_contributiondonor" >
<attribute name="amount" alias="amount" aggregate="sum" />
<attribute name='personid' alias='personid' groupby='true' />
</entity>
</fetch>
Does the sum of every grouped by personId I believe but where do I put a second statement to get the top 3 of these sums?
*This post is locked for comments
I have the same question (0)You should be able to do this by sorting the results by the aggregate, and using the top attribute:
<fetch aggregate="true" top="3" > <entity name="elcn_contributiondonor" > <attribute name="amount" alias="amount" aggregate="sum" /> <attribute name='personid' alias='personid' groupby='true' /> <order alias='amount' descending='true' /> </entity> </fetch>
Alternatively you could use paging to get the first 3 records, instead of top