Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Salesforce
  3. Question
Salesforce

Why am I getting an error when trying to get a unique list from contacts using group by in soql?

Asked by Darsh K May 11, 2023 778 views 1 answer
Share

About this question

I am trying to get a unique list from contacts using a group by but for some reason I am getting an error. If I use Workbench with the same SOQL query it would be fine but I am getting a Syntax Error in Apex.


List lstContact = ([SELECT ID, Name, Email FROM Contact WHERE Email IN: pAddress group by ID, Name, Email]);
Error: Illegal assignment from List to List

Your answer

1 Answer

More Salesforce discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Salesforce Blogs

Guides, tips and career advice on Salesforce from JanBask experts.