Activity Forums Salesforce® Discussions Will below query work? Explain. 1 SELECT COUNT(Id), Name, Address__c FROM Opportunity GROUP BY Name

  • Will below query work? Explain. 1 SELECT COUNT(Id), Name, Address__c FROM Opportunity GROUP BY Name

    Posted by shariq on September 22, 2018 at 9:59 pm

    Will below query work? Explain.

    1
    SELECT COUNT(Id), Name, Address__c FROM Opportunity GROUP BY Name

    shariq replied 5 years, 7 months ago 1 Member · 1 Reply
  • 1 Reply
  • shariq

    Member
    September 22, 2018 at 9:59 pm

    Above query will throw an error.
    Explanation : In Group by clause the columns selected must be either used in Group by clause or in aggregate functions. The Name field is neither used in aggregate methods and in group by clause and hence will result in error “Malformed Query”.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos