0

I have a problem with my SQL where my goal is to create a Data Extension that the records will populate with the number of sent that a subscriber inside in one DE received by the month:

The problem is: ERROR: Automation failed due to system error. What I did wrong?

SELECT count(*) AS TotalSent,  
DATENAME(month, p.EventDate) as [Month],
p.SubscriberKey as SubscriberKey
FROM _Sent p 
INNER JOIN [Clients_DE] B ON p.SubscriberKey = B.AccountID
WHERE p.EventDate BETWEEN GETDATE()-30 AND GETDATE()
GROUP BY p.EventDate, p.SubscriberKey
HAVING COUNT(*) > 0
2
  • 1
    how long does it run before you see that error? Commented Jul 22, 2019 at 15:01
  • 2
    Do you have primary key setup on your target DE? also review your field length..
    – EazyE
    Commented Jul 22, 2019 at 15:08

1 Answer 1

7

I am answering under the assumption that this activity is erroring after about 30 minutes due to a timeout. SubscriberKey is not an indexed field on the _Sent data view. Ideally, when joining the send / open / click views together, one would join these together on SubscriberID, JobID, ListID, BatchID. Since for this use case you are not joining these views together but rather a Custom Object to the view, it would be more performant to join on the SubscriberID field from _Sent back to your DE. It might take a little more data staging. By that I mean, you might need to query the _Subscriber data view to get the SubscriberID staged into your Clients_DE data extension. If you are able to do that, joining from _Sent to Clients_DE on SubscriberID will perform more efficiently.

Hope this helps.

1
  • you can also copy the _Sent DataView over into a Data Extension (via an automation) and reference this instead if you do not need real time results. Data Extensions are processed at a much more efficient rate than DataViews. Commented Jul 22, 2019 at 19:00

You must log in to answer this question.

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