# Dormant Accounts

**Type:** SOQL · **Difficulty:** Hard · **Topics:** Anti-Join, Date Literals, Semi-Join

Practice this problem interactively (write and run your SOQL against realistic data): https://www.forcechallenges.com/problems/dormant-accounts

## Problem

**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:
1. Have **at least one** Opportunity (of any stage), and
2. Have **no** Opportunity with a `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**
- Acme has one Opportunity that closed 3 years ago and nothing since. It is dormant, so it is returned.
- Globex has an old Opportunity and another that closed 2 months ago. It is active, so it is excluded.
- Initech has no Opportunities at all. It is excluded.

## Constraints

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.

---
Source: ForceChallenges · last updated 2026-10-23
