Scenario The enterprise sales team wants executive sponsors for its biggest live deals. They need the senior Contacts at customers that currently have a large Opportunity in the final negotiation stage, so an executive can reach out personally.
Task
Write one SOQL query on Contact that returns Contacts who meet both conditions:
Title contains VP, or contains Chief, or starts with Director.Negotiation/Review with an Amount greater than 250,000.Sort the result by the Account name, then by the Contact's last name.
Expected output
One row per Contact with the columns Id, Name, Title and Account.Name.
Example
Use one query on Contact. Combine the title conditions with OR inside parentheses, then AND them with a semi-join on Opportunity. Read the account name through the parent relationship (Account.Name). Order by Account.Name, then LastName.
9 row(s), order checked
| # | Id | Name | Title | Account.Name |
|---|---|---|---|---|
| 1 | 003000000000001AAA | First 1 Last 1 | VP Sales | Account 2 |
| 2 | 003000000000005AAA | First 5 Last 5 | VP Sales | Account 2 |
| 3 | 003000000000009AAA | First 9 Last 9 | VP Sales | Account 2 |
| 4 | 003000000000010AAA | First 10 Last 10 | Chief Executive Officer | Account 3 |
| 5 | 003000000000002AAA | First 2 Last 2 | Chief Executive Officer | Account 3 |
| 6 | 003000000000006AAA | First 6 Last 6 | Chief Executive Officer | Account 3 |
| 7 | 003000000000011AAA | First 11 Last 11 | Director Sales | Account 4 |
| 8 | 003000000000003AAA | First 3 Last 3 | Director Sales | Account 4 |
| 9 | 003000000000007AAA | First 7 Last 7 | Director Sales | Account 4 |