• In this example I am sorting by Year And Month. just by including month number in GROUP BY am now able to sort by year and month number. I don't have to select month number.

    SELECT [Year] = DATENAME(yyyy,SomeDateTime),

    [Month] = DATENAME(mm,SomeDateTime),

    Amount = SUM(SomeAmount)

    FROM #MyHead

    WHERE SomeDateTime >= '2009-06-01' AND SomeDateTime < '2011'

    GROUP BY DATENAME(yyyy,SomeDateTime),DATEPART(m,SomeDateTime),DATENAME(mm,SomeDateTime)

    ORDER BY 1,DATEPART(m,SomeDateTime)

    ;