function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
surveyforce1.3960136686126697E12surveyforce1.3960136686126697E12 

Need to find those cases having 200 child cases.

Can anyone please help me in querying those cases having more than 200 child cases.

Need to find those cases having 200 child cases.

Please help...!!!
Yogesh KulkarniYogesh Kulkarni
select ParentCaseID, count(ParentCaseID) from case group by ParentCaseID having count(ParentCaseID) > 200.

here the ParentCaseID is the column which represents the self reference.
surveyforce1.3960136686126697E12surveyforce1.3960136686126697E12
Getting below error 

Select ParentID, count(ParentID) from case group by ParentID
^
ERROR at Row:1:Column:24
Grouped field should not be aggregated: ParentId
Salesforce DeveloperSalesforce Developer
Try this 

select ParentCaseID from case group by ParentCaseID having count(ParentCaseID) > 200.


 
Deepak BalurDeepak Balur
Try this: Select count(c.ParentId), c.Id From Case c group by c.Id