Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
SELECT accountid, name,, account.edit_date_funded__c, 
                  account.createddate, date_lead__c, ln_score_again__c, 
                  createddate, lead.ln_score__c 
FROM Opportunity
WHERE accountid IN (select id from account) 
        AND accountid IN (select convertedaccountid from lead)

I get an error for lead.ln_score__c or when I try to select anything from lead.

"Didn't understand relationship 'lead' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name."

Can someone tell me what I need to fix.

Thank you!

share|improve this question
up vote 3 down vote accepted

There is no field called lead on the Opportunity. You can see all of the available fields in the Opportunity object documentation.

There is a field called ConvertedOpportunityId on the Lead object which will be set if the Lead has been converted to an Opportunity. You can query from the Lead to the Opportunity field through it. For example:

Select Id, ConvertedOpportunity.Name
From Lead

If you have a custom Lookup field on the Opportunity for a Lead then you would access it by appending the ‘__r’ as the error states. For example: lead__r.ln_score__c.

Salesforce has good explanation of Relationship Queries in their docs that might be helpful.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.