You need to sign in to do that
Don't have an account?
Casey Hardesty 10
Soql query to pull Leads not attached to any campaigns
Hey everybody,
I'm running into a challenge that is probably very easy but I'm struggling with it. I need to write a SOQL query that will simple pull all Leads not attached to a Campaign. Here is what I've come up with so far but it is definitely not working...
SELECT Id, (Select Id From CampaignMembers WHERE Id = Null) FROM Lead WHERE CreatedDate >= 2016-03-13T00:00:00Z
When I go through the results, most of these are indeed attached to a campaign so not sure what I'm doing wrong.
Any ideas? Thanks in advance.
I'm running into a challenge that is probably very easy but I'm struggling with it. I need to write a SOQL query that will simple pull all Leads not attached to a Campaign. Here is what I've come up with so far but it is definitely not working...
SELECT Id, (Select Id From CampaignMembers WHERE Id = Null) FROM Lead WHERE CreatedDate >= 2016-03-13T00:00:00Z
When I go through the results, most of these are indeed attached to a campaign so not sure what I'm doing wrong.
Any ideas? Thanks in advance.
So, you could do the following:
Select Id from Lead where Id not in (Select LeadId from CampaignMember) AND CreatedDate >= 2016-03-13T00:00:00Z
All Answers
So, you could do the following:
Select Id from Lead where Id not in (Select LeadId from CampaignMember) AND CreatedDate >= 2016-03-13T00:00:00Z
You might want to qualify that the lead has not been converted to a contact:
Select Id,name,owner.name from Lead where Id not in (Select LeadId from CampaignMember) and isconverted = false
having said that, I'm not sure why that's different to using [ status != 'Qualified' ]
...learning all the time.