I want to pull my email data from MC into Market Intelligence (Datorama) by subscriber ID and include enterprise attributes. The best way I have found thus far is to create a DE with the needed info and use the MC Data Extension API in Datorama to ingest. I need a query that will create a daily file of email activity in MC. I have tried the following, but it does not pull all the information. For testing purposes I limited the query to two emailnames as seen in the Where statement. If I run this query for just one of the emailnames at a time I get the correct numbers of Opens, Sends and clicks. (comparing it to a report pulled from MC). When I run the query with both email names one email has the correct number of opens, send, clicks, but the other has a much lower number than it should. Why is the query not pulling the correct numbers for both emails?
Select
s.SubscriberID,
s.SubscriberKey,
s.jobid,
s.eventdate as SentDate,
j.emailname,
o.eventdate as OpenDate,
c.eventdate as ClickDate,
c.linkname as LinkName
From
_sent s
Left Join _job j on s.jobid = j.jobid
Left Join _Open o on s.jobid =o.jobid
AND s.subscriberid = o.subscriberid
AND s.ListID = o.ListID
and s.BatchID = o.BatchID
AND o.ISUnique = 1
Left Join _click c on s.jobid = c.jobid
AND s.ListID = o.ListID
and s.BatchID = o.BatchID
and s.subscriberid = c.subscriberid
AND c.ISUnique = 1
Where emailname IN ('IC_InsiderToday_Employee_28-Oct-2022_Null_Null_Null','IC_InsiderToday_Employee_28-Nov-2022_Null_Null_Null')