I want to check if all the records have the same values for "Group__c" field and throw a message if the values are different.
If all the records are of the same group(Group-A in this example), then no need to display an error. Since, the 3rd record belongs to Group-B - I want to display a message.
My SOQL query:
List <EmployeeContact__c> = [SELECT ID, Company__c, Contact__c, Country__c, Group__c FROM EmployeeContact__c WHERE Parent__c = 'Parent-1' GROUP BY Group__c ] ; System.Debug('All employees for Parent-1 should be of same group');
How to query if there are any distinct values?