is it possible to use ORDER BY column not in the GROUP BY?
Apply another aggregate, so how about;
order by min([date_in])
Order by the same expression you're grouping by.
It is better to group and order on the DATE
representation of the month.
In SQL Server 2008
that would be:
SELECT material, SUM([Amount]) AS [Amount], DATEADD(d, 1 - DAY(GETDATE()), CAST(GETDATE() AS DATE))FROM [rec_stats]GROUP BY material, DATEADD(d, 1 - DAY(GETDATE()), CAST(GETDATE() AS DATE))ORDER BY material, DATEADD(d, 1 - DAY(GETDATE()), CAST(GETDATE() AS DATE))