You need to sign in to do that
Don't have an account?
Need help
Hi,
I have this SOQL. MemberNumbers is a list which contains membership numbers. I need to retrieve latest record of the lead which matches memership number in membernumbers list. because lead may have duplicate records with the same membership numbers.
SOQL: //Lead Map
Map<string,Lead> LeadMap = new Map<string,Lead>();
for( Lead lead:[select customer__c,
status,
createddate,
Membership_Number__c
from Lead
where Membership_Number__c in :memberNumbers]){
leadMap.put(lead.Membership_Number__c,lead);
}
I tried by adding 'limit 1 ' at the last . but it will retrieve only one record regardless ofdifferent membership numbers. I think i need to use aggregate functions. I tried with them too. May be I did not use them in correct way.
Any suggestions?
Thanks,
Neeraja.
I couldn't find it in the docs, but I think you can sort SOQL (SQL syntax is something like "ORDER BY CreateDate").
If you can't sort in SOQL, you can in a list so you could query by CreatedDate (limit 1000 if not on Spring '10 yet), and then sort with the list method, and then do a 2nd query to find only the members from that first created date.