Customers Who Have Bought
Intermediate SolvedCustomer success wants each account that has closed at least one deal, listed once, to invite to a reference programme.
Return the Name of every Account that has at least one Opportunity in stage Closed Won. Each account appears once.
Sample data
Account 4 records
| Name |
|---|
| Acme Cloud |
| Bluefin Bank |
| Corex Labs |
| Delta Retail |
Opportunity 5 records
| Name | StageName | Amount | CloseDate | Account |
|---|---|---|---|---|
| Acme year one | Closed Won | 40,000 | today + 30 days | Acme Cloud |
| Acme year two | Closed Won | 45,000 | today + 30 days | Acme Cloud |
| Bluefin pilot | Prospecting | 15,000 | today + 30 days | Bluefin Bank |
| Corex lost bid | Closed Lost | 30,000 | today + 30 days | Corex Labs |
| Corex win | Closed Won | 22,000 | today + 30 days | Corex Labs |
Expected result on the sample
| Name |
|---|
| Acme Cloud |
| Corex Labs |
Row order does not matter. Only the columns above are compared; extra columns in your SELECT are fine.
Hints
- Filter Account by
Id IN (SELECT AccountId FROM Opportunity WHERE ...).
What this tests
A semi-join (Id IN (SELECT AccountId FROM ...)) filters parents by a condition on their children and returns each parent once. Querying the Opportunities and reading Account.Name gives one row per deal instead, so a customer with two wins shows up twice.
Datasets
Solved on this device only. Sign in with Google to keep your progress across devices.
Run on sample executes your query against the sample data shown on the left and displays the rows it returns. Submit checks it against the sample plus 2 hidden datasets, comparing your rows with the expected rows on each. Queries run in a real Salesforce org; the data is inserted for your run and rolled back afterwards.