You need to sign in to do that
Don't have an account?
jova
Simple SOQL Query
Hey All,
I'm trying to retrieve a list of distinct Account IDs by the most recent closed--won opportunity.
In theory, the query below would get me somewhat close, but of course I can't structure my query this way....
SELECT id, (SELECT id from Opportunity WHERE iswon = true ORDER BY closedate DESC) from Account
any kind and smart souls out there?
Hello jova, what is 'iswon' in the inner query ? If it is a custom field , use iswon__c or its API name and frame your query as:
Try this
Hey
You can nest your query like that, but you may have to remove the ORDER BY and DESC keywords. To get a distinct list you can push the Id values into a SET e.g.
Set<Id> distinctIds = new Set<Id>();
for(Account a: Accounts){
distinctIds.add(a.id);
}
Wes