SOQL to get Account ids where Contact count is greater than 2

SOQL to get Account ids where Contact count is greater than 2

Sample Query:

SELECT AccountId 
FROM Contact 
GROUP BY AccountId 
HAVING COUNT(AccountId) > 2

This SOQL query is used to get Account Ids where related Contacts count is greater than 2 for the account records.

Leave a Reply