• David McKinney (8/2/2013)


    Jeff,

    Before my post, I did in fact (quickly) read through all the comments...and the month function was mentioned a number of times already. I didn't see any added value in requoting it....but yes, I do realise that you also have to include it in the 'group by' if that's what you're referring to.

    One of your previous comments refers to the sort not happening correctly when using the month function...in fact that's not the case...the sort works fine. ...

    David.

    I agree, this works perfectly:

    SELECT [Month] = datename(mm,min(SomeDateTime)),

    Amount = SUM(SomeAmount)

    FROM #MyHead

    WHERE SomeDateTime >= '2010' AND SomeDateTime < '2011'

    GROUP BY month(SomeDateTime)

    ORDER BY month(SomeDateTime)

    Don't just give the hungry man a fish, teach him how to catch it as well.

    the sqlist