Development questions
Write a SOQL query to count the number of unique Industry values across all Accounts (SELECT COUNT_DISTINCT(Industry) FROM Account).
Use COUNT_DISTINCT() on the field. It counts unique non-null values.
soql
SELECT COUNT_DISTINCT(Industry) FROM Account
In Apex, the result is an AggregateResult and you read it with (Integer) ar.get('expr0').
soqlscenarioaggregate
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?