Scenario The customer-success team wants to re-engage customers that have gone quiet. A dormant Account is one that has done business before but has had no sales activity in the past year.
Task
Write one SOQL query on Account that returns Accounts which:
CloseDate in the last 12 months (LAST_N_MONTHS:12).Accounts that have never had an Opportunity are not dormant, they are simply new, so they must not be returned.
Expected output
One row per dormant 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) with an anti-join (Id NOT IN) against Opportunity. Use the LAST_N_MONTHS date literal for the 12-month window. Accounts that never had an Opportunity must not be returned.
18 row(s), any order
| # | Id | Name |
|---|---|---|
| 1 | 001000000000001AAA | Account 1 |
| 2 | 001000000000014AAA | Account 14 |
| 3 | 001000000000015AAA | Account 15 |
| 4 | 001000000000016AAA | Account 16 |
| 5 | 001000000000017AAA | Account 17 |
| 6 | 001000000000018AAA | Account 18 |
| 7 | 001000000000019AAA | Account 19 |
| 8 | 001000000000020AAA | Account 20 |
| 9 | 001000000000021AAA | Account 21 |
| 10 | 001000000000022AAA | Account 22 |
| 11 | 001000000000023AAA | Account 23 |
| 12 | 001000000000024AAA | Account 24 |
| 13 | 001000000000025AAA | Account 25 |
| 14 | 001000000000026AAA | Account 26 |
| 15 | 001000000000027AAA | Account 27 |
| 16 | 001000000000028AAA | Account 28 |
| 17 | 001000000000029AAA | Account 29 |
| 18 | 001000000000030AAA | Account 30 |