Using Max(count(*)) in ROQL
I have a requirement to get the count of incidents by customer for every agent on our team and display the "preferred" customer (i.e., the customer that has the highest incident count) per agent. I understand this is a classic limit group by problem. However, I am finding it hard to implement in ROQL.
Here is what I have so far:
- I can successfully return the incident count per customer per agent and display them
But what I am struggling with is displaying just the top customer (and related count) for each agent...and ROQL doesn't allow sub queries. Is there a way to do this?