function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
textualtextual 

Aggregate query bringing back mixed record data

ive got an aggregate query where i want the ID of the Opportunity with the greatest Start Date for a particular Account. However, its not just getting the MAX(Start Date), its also beinging back the MAX ID, which isnt what I want, I want the ID of the Opportunity with the MAX DATE. But SOQL wants me to group or Aggregate the ID, which I dont want.
 
[SELECT max(start_date__c) maxDate, AccountId, MAX(Id) useId
                                                FROM Opportunity 
                                                WHERE StageName = 'Signed' 
                                                    AND AccountId in :setIds 
                                                GROUP BY AccountId]

The only piece of information I really need is the ID of the record with the max date, but thats not happening at the moment