1

I want pull out the list of customers that did not click on the mail we sent.

We maintain a SendLog in which we have additional attributes logged (Example: emailname, subject etc.)

I understand that we can use Sent data view. But I wish to use SendLog instead as it has additional fields.

Here is the query I have used to join SendLog & Clicks. But the results is null. Please could anyone help me fix this problem

select  se.EmailAddress,se.TimeStamp as sentdate
from SendLog se
inner join [_click]  cl
on  se.JobID=cl.JobID and se.BatchID=cl.BatchID and se.SubID=cl.SubscriberID
where se.EmailName_ = 'hello'  and cl.SubscriberID is null

2 Answers 2

1

Your issue is you are doing an INNER JOIN, which requires the record to exist in BOTH tables (DEs) in order to be returned. The OPs code is basically saying return all records that match on both tables but are empty on the second one. Since it cannot exist but also not exist, it returns 0.

As you are looking for records that are both in and NOT in the _Click DV, this is causing you to return 0 results.

What you want to do is instead utilize a LEFT JOIN (pulls all results from initial table (de) and any that match in second (de).

By then pulling only records that have a click subID of null, it will remove any matches and will instead only pull those in the send log that are not in click.

Like this:

select  se.EmailAddress
,se.TimeStamp as sentdate
from SendLog se
left join [_click]  cl
on  se.JobID=cl.JobID and se.BatchID=cl.BatchID and se.SubID=cl.SubscriberID
where se.EmailName_ = 'hello'  and cl.SubscriberID is null

Another option too is to instead utilize NOT EXISTS instead of a left join.

Something like:

select  se.EmailAddress
,se.TimeStamp as sentdate
from SendLog se
WHERE NOT EXISTS (
  SELECT TOP 1 cl.SubscriberID FROM [_click]  cl
  WHERE se.JobID=cl.JobID and se.BatchID=cl.BatchID and se.SubID=cl.SubscriberID
)
AND se.EmailName_ = 'hello'

They will likely process and function the same, so its more a matter of preference.

0

Welcome to SFSE!

Please review _Click Data View documentation, where it is shown that the SubscriberID field is not nullable, thus you cannot have WHERE clause with cl.SubscriberID is null and INNER JOIN at the same time, which makes you have 0 records in the result.

You should either adjust conditions in the WHERE clause or select another type of JOIN, depending on what would suit your needs better.

5
  • 1
    This is incorrect. The click subID can be nullable as its a join tothe sendlog. Where an email can be sent but not clicked. so click subID would be null. The issue is the INNER JOIN. Commented Jun 29, 2021 at 12:45
  • 1
    It can be nullable when you use other join types but the field itself is non-nullable and that is a fact. that is what I said in my answer that OP should either adjust WHERE clause conditions or change INNER JOIN to something else but that is his business how to proceed.
    – Niko
    Commented Jun 29, 2021 at 13:07
  • Whether the field is nullable or not in the DV makes no difference in his issue though. And the statement thus you cannot have WHERE clause with cl.SubscriberID is null, which makes you have 0 records in the result. is 100% incorrect. You can have this statement on a join. It is basically using a left join as an exclusion. Commented Jun 29, 2021 at 13:18
  • 1
    I was referring to the OP's SQL where we have INNER JOIN. There is no point to discuss what is generally possible or not, since there are millions of different approaches but each one of them would suit a different purpose.
    – Niko
    Commented Jun 29, 2021 at 13:31
  • With the update your answer is no longer incorrect. Thank you for updating it. And discussing possible or not IS the whole point of forums like these. There are a million different solutions in a million different ways. But this was about an incorrect statement, not possibilities. Commented Jun 29, 2021 at 13:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .