Scenario The sales operations team is reviewing customers who never turned into revenue. They want Accounts where the company has lost at least one deal and has never won any, so they can decide whether the relationship is worth pursuing again.
Task
Write one SOQL query on Account that returns Accounts which:
Closed Lost, andIsWon = true).Accounts with no Opportunities at all are not part of this list. Open Opportunities do not disqualify an Account.
Expected output
One row per matching Account with the columns Id and Name. Row order does not matter.
Example
Use one query on Account that combines a semi-join (Id IN) for Closed Lost Opportunities with an anti-join (Id NOT IN) for won Opportunities. Test won deals with IsWon = true, and lost deals with StageName = 'Closed Lost'.
4 row(s), any order
| # | Id | Name |
|---|---|---|
| 1 | 001000000000001AAA | Account 1 |
| 2 | 001000000000002AAA | Account 2 |
| 3 | 001000000000003AAA | Account 3 |
| 4 | 001000000000004AAA | Account 4 |