Development questions

Write a SOQL query to group Opportunities by the Year and Month of their CloseDate (CALENDAR_YEAR(CloseDate), CALENDAR_MONTH(CloseDate)).

DevelopmentMediumDeloittePwCZS Associates

Group by the date functions CALENDAR_YEAR() and CALENDAR_MONTH(), and alias them so they can be read from the AggregateResult.

soql
SELECT CALENDAR_YEAR(CloseDate) yr, CALENDAR_MONTH(CloseDate) mon, COUNT(Id) cnt, SUM(Amount) total
FROM Opportunity
GROUP BY CALENDAR_YEAR(CloseDate), CALENDAR_MONTH(CloseDate)
ORDER BY CALENDAR_YEAR(CloseDate), CALENDAR_MONTH(CloseDate)
soqlscenariodate-functionsgroup-by