function readOnly(count){ }
Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
[ Select id, name, (select id, name from Contacts) from account ]
Thanks,
Arvind Kumar
select accountid from contact group by accountid having count(id) = 2
Hi Ram,
You need to do certain things to make it work for you -
1. Create one new custom field on Account (Integer type).
2. By using apex, we would rollup number of contacts to this new custom field.
3. Afterwards, you'll have account records with number of contact .
Please let us know, in case you wanting this approach, then i will build code for you Thanks
Map<Id,Integer> mp = new Map<Id,Integer>(); for(Account acc : [Select id, name, (select id, name from Contacts) from account]) { mp.put(acc.id,acc.Contacts.size()); } for(Account acc : [Select Id,Name from Account]) { if(mp!=null && mp.containsKey(acc.id)) { if(mp.get(acc.id)==2) system.debug('aaaa'+ acc.Name); } }
This is second approach. You can retrieve account records which have only 2 contacts.Thanks,Arvind Kumar
Use Below Soql to retrieve an account record with more than 2 contacts.
Thanks,
Arvind Kumar
And read this link. https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_loops_for_SOQL.htm
Use below SOQL to retrive account records which has only 2 contacts
Thanks
Hi Ram,
You need to do certain things to make it work for you -
1. Create one new custom field on Account (Integer type).
2. By using apex, we would rollup number of contacts to this new custom field.
3. Afterwards, you'll have account records with number of contact .
Please let us know, in case you wanting this approach, then i will build code for you
Thanks
Use below code. It will work for you.
This is second approach. You can retrieve account records which have only 2 contacts.
Thanks,
Arvind Kumar