function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
tengeltengel 

SOQL query to select records with a non-unique field?

Hello,

 

I have a custom text field serving as an external, non-unique ID labeled "E_Policy_ID__c." I would like to extract all records for this object where E_Policy_ID__c is NOT unique.

 

Can anyone give any tips on a SOQL query that I can use in Workbench or Data Loader? I'd like to avoid extracting ALL object records and then using Excel sleuthing to find the non-unique rows.

 

Thank you!

Vinita_SFDCVinita_SFDC

Hello,

 

Suppose the object is account, then you can query like:

 

SELECT E_Policy_ID__c FROM Account

 

GROUP BY E_Policy_ID__c

 

HAVING count(E_Policy_ID__c)>1

 

Also i would suggest you to install Dupe Catcher app from appexchange which is free of cost and stops duplication.