I'm running into a very strange issue that I have found no explanation for yet. With SQL Server 2008 and using the GROUP BY it is ordering my columns without any ORDER BY specified. Here is a script that demonstrates the situation.
CREATE TABLE #Values ( FieldValue varchar(50) )
;WITH FieldValues AS
(
SELECT '4' FieldValue UNION ALL
SELECT '3' FieldValue UNION ALL
SELECT '2' FieldValue UNION ALL
SELECT '1' FieldValue
)
INSERT INTO #Values ( FieldValue )
SELECT
FieldValue
FROM FieldValues
-- First SELECT demonstrating they are ordered DESCENDING
SELECT
FieldValue
FROM #Values
-- Second SELECT demonstrating they are ordered ASCENDING
SELECT
FieldValue
FROM #Values
GROUP BY
FieldValue
DROP TABLE #Values
The first SELECT will return
4
3
2
1
The second SELECT will return
1
2
3
4
According to the MSDN Documentation it states: "The GROUP BY clause does not order the result set"