Example: GROUP BY in SOQL


The VP of Sales would like to know how many Opportunities have the Lead Source of ‘Word of Mouth’. Additionally, she would like the number broken down by the Stage.


Use the sample syntax below to write a SOQL query using GROUP BY.

SELECT COUNT(Id), StageName FROM Opportunity WHERE LeadSource= 'Word of Mouth' GROUP BY StageName

Scroll to top