0

I want to order the result of my query result and put it via Query activity into a data extension (DE has no primary key). The order by MAWE is pretty important for me.

select 
count (SubscriberKey) AS amount,
country,
MAWE,
variant 
from Sendfinal1 
group by country,MAWE,variant 
order by MAWE,country

SF seems not to accept the order by:

Message: An error occurred while checking the query syntax. Errors: The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP, OFFSET or FOR XML is also specified.

Is there a workaround for that?

  • 1
    have you checked this topic? salesforce.stackexchange.com/questions/187273/… – Duicug Jan 31 at 11:11
  • 3
    As a quick but dirty workaround, you could use SELECT TOP 9223372036854775807 in the first line to get all the records – zuzannamj Jan 31 at 12:50
  • 1
    A select top 100 percent will also work – Adam Spriggs Jan 31 at 14:24
  • 1
    @AdamSpriggs I thought so as well, but couldn't get the PERCENT to work.. – zuzannamj Jan 31 at 14:29
  • 1
    @Zuzannamj - Yeah, I noticed it does not work at all (PERCENT) in Query Studio, BUT it works fine in a real query. TOP 100 PERCENT is viable, just not in query studio – Gortonington Jan 31 at 14:34

Browse other questions tagged or ask your own question.