Industries Worth a Campaign

Advanced

Marketing only builds an industry campaign when there are more than two accounts to send it to.

Return each Industry that has more than two Accounts, with the account count aliased accounts.

Sample data

Account 6 records

NameIndustry
Acme CloudTechnology
Corex LabsTechnology
Echo SystemsTechnology
Bluefin BankBanking
Harbor CreditBanking
Delta RetailRetail

Expected result on the sample

Industryaccounts
Technology3

Row order does not matter. Only the columns above are compared; extra columns in your SELECT are fine.

Hints
  • Group by Industry and count with COUNT(Id) accounts.
  • Filter the groups with HAVING COUNT(Id) > 2.

What this tests

WHERE filters rows before they are grouped; HAVING filters the groups after the counts exist. A condition on COUNT, SUM or another aggregate can only go in HAVING. The off-by-one is the other trap here: "more than two" is > 2.

SOQL

Run on sample executes your query against the sample data shown on the left and displays the rows it returns. Submit checks it against the sample plus 2 hidden datasets, comparing your rows with the expected rows on each. Queries run in a real Salesforce org; the data is inserted for your run and rolled back afterwards.