# Recent High-Priority Case Escalations

**Type:** SOQL · **Difficulty:** Hard · **Topics:** Parent-to-Child, Date Literals, Semi-Join

Practice this problem interactively (write and run your SOQL against realistic data): https://www.forcechallenges.com/problems/recent-high-priority-case-escalations

## Problem

**Scenario**
The support director reviews escalations every week. She wants to see which customers have raised urgent problems recently, together with the actual Cases, so the account team can follow up.

**Task**
Write one SOQL query on `Account` that:
1. Returns only Accounts that have at least one Case with `Priority = 'High'` created in the **last 30 days** (`LAST_N_DAYS:30`).
2. Includes, for each of those Accounts, a child list of its matching Cases showing `CaseNumber` and `Subject`.
3. Lists only the matching Cases in that child list: Cases that are not High priority or are older than 30 days must not appear.

**Expected output**
One row per qualifying Account with `Id`, `Name` and a nested `Cases` list containing `CaseNumber` and `Subject`. Row order does not matter.

**Example**
Account Acme has a High Case from 5 days ago (Subject Outage) and a Medium Case from 3 days ago. Account Globex has a High Case from 90 days ago. Account Initech has no Cases.
- Acme is returned with only the Outage Case in its list.
- Globex is excluded because its High Case is too old.
- Initech is excluded because it has no Cases.

## Constraints

Use a single query on Account: a parent-to-child subquery on the Cases relationship for the case list and a semi-join (Id IN) to exclude Accounts without matching Cases. Use the LAST_N_DAYS date literal, not a hardcoded date. Apply the same two Case filters inside the subquery and inside the semi-join.

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