May 9, 2019 at 12:00 am
Comments posted to this topic are about the item Strange Sorting
May 9, 2019 at 5:36 am
That is strange.
reading it, it seems it would sort by DATENAME(Month), but testing shows otherwise.
Interesting question, thanks Steve
____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
May 9, 2019 at 1:48 pm
Thanks for this interesting T-SQL question Steve.
May 9, 2019 at 2:16 pm
nice and easy, cheers Steve
---------------------------------------------------------------------------------------
The more you know, the more you know that you dont know
May 9, 2019 at 3:57 pm
This was interesting to me as well when I stumbled on it.
May 9, 2019 at 4:11 pm
Arg! I clicked the wrong one! I got so excited because I new that it would list it by month name yet be in the proper order (month number). This is a pretty cool trick I learned from Jeff Moden!
LinkedIn: https://www.linkedin.com/in/sqlrv
Website: https://www.sqlrv.com
May 9, 2019 at 5:52 pm
Great question... I would have used the following sort instead for month number:
ORDER BY DATEPART(mm,oh.OrderDate)
May 9, 2019 at 6:02 pm
I thought the same thing initially, but it won't work because DATEPART(mm,oh.OrderDate) is not part of the GROUP BY whereas DATENAME(mm,oh.OrderDate) is.
LinkedIn: https://www.linkedin.com/in/sqlrv
Website: https://www.sqlrv.com
May 9, 2019 at 8:26 pm
Ahhh yes... Absolutely right... Always a gotcha… 🙂
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply