Can you expand on what you are asking? More than 10 what? You want accounts that have more than 10 contacts? Are you trying to do this in Apex? Please let us know what your end goal is and we can help you reach it.
To achieve this need to work with SOQL Aggregate Functions, Here is the sample code for your requirement.
Apex code:
public class Accts_ids {
public AggregateResult[] results { get {
return [SELECT accountid idsss, count(id) contactssss FROM Contact GROUP BY Accountid HAVING count(id) > 10];
}
}
}
Visualforce page code:
<apex:page controller="MyController">
<apex:pageBlock title="AccountID's which associated with more than 5 contacts">
<apex:pageBlockTable value="{!results}" var="r">
<apex:column value="{!r['idsss']}"/>
<apex:column value="{!r['contactssss']}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
Hi,
Please use below query to get the Account which has more than 10 contacts:
SELECT AccountId, COUNT(Id)
FROM Contact
GROUP BY AccountId
HAVING COUNT(Id) > 10
All Answers
Hi,
Please use below query to get the Account which has more than 10 contacts:
SELECT AccountId, COUNT(Id)
FROM Contact
GROUP BY AccountId
HAVING COUNT(Id) > 10
To achieve this need to work with SOQL Aggregate Functions, Here is the sample code for your requirement.
Apex code: Visualforce page code:
please refer this link https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_SOQL_agg_fns.htm
Hope this helps you!
Best Regards,
Rakesh Thota.
Hi,
If my solution works for you.
Please mark it as the best answer.
Thanks
Deepak