Development questions
Write a SOQL query to group Opportunities by the Year and Month of their CloseDate (CALENDAR_YEAR(CloseDate), CALENDAR_MONTH(CloseDate)).
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
More Development questions
- What is an Apex Trigger in Salesforce and when should you use it over Flows?
- What is the difference between before triggers and after triggers?
- Explain all Trigger context variables (isInsert, isUpdate, isDelete, isUndelete, isBefore, isAfter, isExecuting, size, operationType).
- What is the difference between Trigger.new and Trigger.old?
- In which trigger events are Trigger.new and Trigger.newMap available?
- In which trigger events are Trigger.old and Trigger.oldMap available?