+ Start a Discussion
Sigmund VanDammeSigmund VanDamme 

SOQL / Workbench Query Help leads/opps

I need to get all of the leads that do not have "Demo" In the name of the opportunity it was converted to.

So I need to get all leads and, if they have been converted, check the name for "demo in it".  I.e. a left outer join on Leads to Opportunities

I have tried all the following without any luck in workbench:
  • Tried to Reference ConvertedOpportunityId__r.Name in the query i.e.: SELECT id, ConvertedOpportunityId FROM Lead where (Not ConvertedOpportunityId__r.Name like '%demo%') - this gives me a syntax error (Didn't understand relationship 'ConvertedOpportunityId__r' in field path)
Any help much appreciated.

 
Best Answer chosen by Sigmund VanDamme
Karthik PKarthik P
Hi Sigmund,

Please try with the below query and mark this as answer if it works the way you want.
 
SELECT id, ConvertedOpportunityId,ConvertedOpportunity.Name FROM Lead where ConvertedOpportunityId <> '' and (NOT ConvertedOpportunity.Name like '%Demo%')

Thanks,
Karthik

All Answers

Karthik PKarthik P
Hi Sigmund,

Please try with the below query and mark this as answer if it works the way you want.
 
SELECT id, ConvertedOpportunityId,ConvertedOpportunity.Name FROM Lead where ConvertedOpportunityId <> '' and (NOT ConvertedOpportunity.Name like '%Demo%')

Thanks,
Karthik
This was selected as the best answer
Sigmund VanDammeSigmund VanDamme
Worked like a charm!  Thanks so much.