Activity Forums Salesforce® Discussions Explain briefly about GROUP BY with the syntax in Salesforce?

  • Nikita

    Member
    August 28, 2019 at 6:52 am

    Hi Saddam,

    You can use the GROUP BY option in a SOQL query to avoid iterating through individual query results. That is, you specify a group of records instead of processing many individual records.
    You can use GROUP BY with aggregate functions, such as SUM() or MAX(), to summarize the data and enable you to roll up query results rather than having to process the individual records in your code.

    The following query returns the distinct set of values stored in the LeadSource field.

    SELECT LeadSource
    FROM Lead
    GROUP BY LeadSource

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos