I need help!
I have this query
SELECT TOP 100 PERCENT *
FROM [dbo].[Conversion_imageTiles]
WHERE [old_file] = 'tileWeir-E-W-U-D.gif'
ORDER BY [old_file],[static_class]
It produces these results..
Notice the field [static_class] is in alphabetical order....
But this is a sub query...
SELECT [old_file]
,STRING_AGG(CONCAT([static_class],' ',[rotation]),' ')[static_class]
FROM (
SELECT TOP 100 PERCENT *
FROM [dbo].[Conversion_imageTiles]
WHERE [old_file] = 'tileWeir-E-W-U-D.gif'
ORDER BY [old_file],[static_class]
) a
WHERE [old_file] = 'tileWeir-E-W-U-D.gif'
GROUP BY [old_file]
ORDER BY [old_file],[static_class]
See, there it is in the middle - popping out a result set that has [static_class] in alphabetical order.. So why are the results of the full query this..
Notice [static_class] is backwards, I would expect it to start with 'bypass-weir..' Changing the ORDER clauses has no effect... its ALWAYS in that order...
Help!
EDIT: I wondered if it was due to the internal ordering based off the [id] column in the internal sub query.
Removing it:
SELECT TOP 100 PERCENT [old_file],[static_class],[rotation]
FROM [dbo].[Conversion_imageTiles]
WHERE [old_file] = 'tileWeir-E-W-U-D.gif'
ORDER BY [old_file],[static_class]
Had no effect