Salesforce Platform Developer I (legacy) — Question 13
Which SOQL query successfully returns the Accounts grouped by name?
Answer options
- A. SELECT Type, Max(CreatedDate) FROM Account GROUP BY Name
- B. SELECT Name, Max(CreatedDate) FROM Account GROUP BY Name
- C. SELECT Id, Type, Max(CreatedDate) FROM Account GROUP BY Name
- D. SELECT Type, Name, Max(CreatedDate) FROM Account GROUP BY Name LIMIT 5
Correct answer: B
Explanation
Option B is correct because it selects the Name field and groups the results by Name, which is the requirement. Options A, C, and D include additional fields that are not necessary for the grouping, which makes them less appropriate for simply returning Accounts grouped by name.