Group__c has a lookup relationship to
Account. What should be the query to fetch the number of
Account records which have more then N
Group__c child records?
N can be anything like 3,5 etc.
You can use the
HAVING clause and an aggregate query:
Integer matchingAccounts = [ SELECT count(Id) records, Account__c FROM Group__c GROUP BY Account__c HAVING count(Id) > :numberOfChildren ].size();