Scenario Sales leadership wants to know which customer industries bring in the most closed revenue. Every Opportunity belongs to an Account, and every Account has an Industry.
Task
Write one SOQL query on Opportunity that:
IsWon = true).Account.Industry).Amount is greater than 1,000,000.Expected output
One row per industry with two columns: Account.Industry and the total won amount. Leave the total un-aliased so it comes back as expr0.
Example Won Opportunities: Retail 600,000 + 700,000, Finance 1,500,000, Healthcare 400,000.
Result: Finance (1,500,000), then Retail (1,300,000).
Use one query with GROUP BY on a parent field, HAVING on an aggregate, ORDER BY on an aggregate, and LIMIT. Filter on IsWon, not on StageName text.
2 row(s), order checked
| # | expr0 | Account.Industry |
|---|---|---|
| 1 | 91500000 | Retail |
| 2 | 88500000 | Finance |