Development questions
Explain the difference between GROUP BY, GROUP BY ROLLUP, and GROUP BY CUBE in SOQL.
GROUP BYgroups rows by field values and gives one row per group.GROUP BY ROLLUP(f1, f2)adds subtotal rows for each level plus a grand total. UseGROUPING(field)to detect subtotal rows.GROUP BY CUBE(f1, f2)adds subtotals for all combinations of the fields (more rows than ROLLUP).
soql
SELECT LeadSource, Rating, COUNT(Id) FROM Lead GROUP BY ROLLUP(LeadSource, Rating)
SELECT Type, BillingCountry, COUNT(Id) FROM Account GROUP BY CUBE(Type, BillingCountry)
soqlaggregategroup-byrollupcube
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?