multiple records might have the external id. I want to Query all the duplicate Records ,I want to know all the Records which is having same external Id
How can I perform this query?
The Answer is:
SELECT External__c, count(Id) records FROM MyObject__c GROUP BY External__c HAVING count(Id) > 1
If you are open to using Apex, you can generate a Set based on the above. If your volume is low enough, you can do it all in one go:
Set<String> externalIds = new Set<String>(); for (AggregateResult aggregate : [ SELECT External__c FROM MyObject__c GROUP BY External__c HAVING count(Id) > 1 ]) externalIds.add((String)aggregate.get('External__c')); List<MyObject__c> duplicates = [ SELECT Id, External__c FROM MyObject__c WHERE External IN :externalIds ];
I am Having Large Number of Records,How to Query? then I want to know all records which is having same External Id,Guide Me for the Answer