• RichTheCoder
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

Hi,

 

Hope someone can lend a hand here.  I have a list of email addresses (:emails).  I would like to then query all the email addresses against our contacts email addresses, then if it finds only 1 contact with that email address, return the ID etc.  So it must pretty much ignore not match for emails and ignore where count email != 1.

 

I have tried researching this but I battling to find an answer.  I have currently got the below SOQL statement:

 

[SELECT Id, AccountId, COUNT(Email) FROM Contact WHERE Email IN :emails GROUP BY Id, AccountId HAVING COUNT(Email) = 1];

 

Thanks in advance,

Peter