# Hot Accounts with Their Contacts

**Type:** SOQL · **Difficulty:** Hard · **Topics:** Relationships, Parent-to-Child, Subquery

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

## Problem

Return every **Account** with `Rating = 'Hot'`, together with the **last names of its Contacts**, in a single query.

Select `Name` and a parent-to-child subquery on the `Contacts` relationship returning `LastName` (sorted by `LastName`). Sort accounts by `Name`.

Accounts with no contacts must still be returned — their `Contacts` value is `null`.

## Constraints

- One query, using a relationship subquery `(SELECT ... FROM Contacts ...)`.
- Row order is checked (accounts and contacts).

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