Scenario The VP of Sales wants a one-line view of each customer: the single biggest deal the company has on file for it. This helps her prepare executive conversations without scrolling through every Opportunity.
Task
Write one SOQL query on Account that:
Amount.Amount), showing Name and Amount.Amount is null when picking the largest.Expected output
One row per qualifying Account with Id, Name and a nested Opportunities list that contains exactly one record with Name and Amount. Row order does not matter.
Example
Use one query on Account with a child subquery on the Opportunities relationship that uses ORDER BY Amount DESC and LIMIT 1. Ignore Opportunities whose Amount is null, and do not return Accounts that have no Opportunity with an Amount.
5 row(s), any order
| # | Id | Name | Opportunities |
|---|---|---|---|
| 1 | 001000000000001AAA | Account 1 | [1 record] |
| 2 | 001000000000002AAA | Account 2 | [1 record] |
| 3 | 001000000000003AAA | Account 3 | [1 record] |
| 4 | 001000000000004AAA | Account 4 | [1 record] |
| 5 | 001000000000005AAA | Account 5 | [1 record] |