How can I get a list of records where two fields have the same or different values using SOQL?

How can I get a list of records where two fields have the same or different values using SOQL?

1. Create a formula field

IF(Field1__c != Field2__c, 1, 0)

2. Write a SOQL as mentioned below

SELECT Id from Account WHERE FormulaField__c = 1

Cheers!!!

Leave a Reply