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