# Contacts at Pipeline-Only Accounts

**Type:** SOQL · **Difficulty:** Hard · **Topics:** Semi-Join, Anti-Join, Relationship Query

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

## Problem

**Scenario**
The customer-success team wants to reach out to people at customers who are still in the middle of their first purchase. These are Accounts that currently have a deal in progress but have never closed a won deal with the company.

**Task**
Write one SOQL query on `Contact` that returns Contacts whose Account:
1. Has **at least one open Opportunity** (`IsClosed = false`), and
2. Has **never won** an Opportunity (no Opportunity with `IsWon = true`).

Sort the result by the Account name, then by the Contact's last name.

**Expected output**
One row per Contact with the columns `Id`, `Name` and `Account.Name`.

**Example**
- Acme has an open Proposal and a Closed Lost deal. Its Contacts are returned (open deal, no win).
- Globex has an open deal and also a Closed Won deal. Its Contacts are excluded because it has won before.
- Initech has only a Closed Won deal. Its Contacts are excluded (no open deal).
- Umbrella has no Opportunities. Its Contacts are excluded.

## Constraints

Use one query on Contact that combines a semi-join (AccountId IN) on open Opportunities with an anti-join (AccountId NOT IN) on won Opportunities. Read the account name through Account.Name. Order by Account.Name, then LastName.

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