Industries Worth a Campaign
Advanced SolvedMarketing 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
| Name | Industry |
|---|---|
| Acme Cloud | Technology |
| Corex Labs | Technology |
| Echo Systems | Technology |
| Bluefin Bank | Banking |
| Harbor Credit | Banking |
| Delta Retail | Retail |
Expected result on the sample
| Industry | accounts |
|---|---|
| Technology | 3 |
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.
Datasets
Solved on this device only. Sign in with Google to keep your progress across devices.
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.