Scenario Sales managers want a daily list of customers with live deals, showing exactly which deals are still in play and which are the biggest. Customers with nothing open should not clutter the list.
Task
Write one SOQL query on Account that:
IsClosed = false).Id, Name and Amount, sorted by Amount highest first.Name ascending.Expected output
One row per Account with Id, Name and a nested Opportunities list of Id, Name and Amount. Closed Opportunities must not appear in the child list.
Example
Use one query on Account with a child subquery on the Opportunities relationship and a semi-join (Id IN) on open Opportunities. Apply IsClosed = false in both the subquery and the semi-join. Sort the child list by Amount descending and the Accounts by Name ascending.
8 row(s), order checked
| # | Id | Name | Opportunities |
|---|---|---|---|
| 1 | 001000000000001AAA | Account 1 | [3 records] |
| 2 | 001000000000002AAA | Account 2 | [3 records] |
| 3 | 001000000000003AAA | Account 3 | [3 records] |
| 4 | 001000000000004AAA | Account 4 | [3 records] |
| 5 | 001000000000005AAA | Account 5 | [3 records] |
| 6 | 001000000000006AAA | Account 6 | [3 records] |
| 7 | 001000000000007AAA | Account 7 | [3 records] |
| 8 | 001000000000008AAA | Account 8 | [3 records] |