Each view has some type of event-date creation. When creating my automation and appending the SQL query, I want use ORDER BY on event date in the query but it does not work with views according to MC.

Is there anyway to order the date in ascending order

,c.EventDate AT TIME ZONE 'Central Standard Time' AT TIME ZONE 'UTC' as EventDate
,cal.User_uuid__c AS UserUUID

FROM _Complaint c with(nolock)
inner join [contact_all] cal
on c.subscriberKey = cal.id
ORDER BY c.EventDate
  • What is the use case to have the records sorted within the DE?
    – EazyE
    Feb 22 '20 at 14:27
  • Have a look at salesforce.stackexchange.com/questions/128706/… You need to use TOP to get ORBER BY to work. Not sure tho if it is necessary. Please state your use case.
    – DonL
    Feb 24 '20 at 7:28

An SQL query activity ultimately inserts/updates a Relational Database Table - "Data Extension". Relational Database Tables don't sort data within them, unless you create a clustered index on one or more of the columns (you can't do this in SFMC).

So, even if you could sort the output of your query, it would be inserted into the results data extension as an unsorted heap. This is the reason why placing order by clauses in your query activities isn't supported - it would be futile to do and would be expensive in terms of query performance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.