SOQL Query to Group By Month and Year

SELECT Count(Id), Calendar_Year(CloseDate), Calendar_Month(CloseDate)
FROM Opportunity
WHERE Stage = 'Closed Won'
GROUP BY Calendar_Year(CloseDate), Calendar_Month(CloseDate)
ORDER BY Count(Id) DESC

Leave a Reply