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
krishna guptakrishna gupta 

I want to get the count of Account records which is having count of contact records greater than 100. can anyone provide me the SOQL query or any other way to achieve this

Currently I am using the below  code, but my account  record counts is more and it is not taking more than 200 records at a time, and if i am not providing the limit, then it is throwing error.
Select AccountId, count(id) from Contact group by AccountId having count(id)  > 100 limit 200

 
Amit Chaudhary 8Amit Chaudhary 8
Below query will give list if Account where contact count is more then 100 .Please try below query
Select AccountId, count(id) from Contact group by AccountId having count(AccountId)  > 100

Let us know if this will help you

List<Contact> lstCont = [Select AccountId, count(id) from Contact group by AccountId having count(AccountId) > 100];
System.debug(lstCont.size() );