I'm trying to sort using the months name, when I have it in numbers everything is working, but when I try to make a select like this
SELECT DISTINCT CONVERT(nvarchar(50), DATENAME(m, date) + ', ' + DATENAME(yyyy,date)) as date From MyTable In my output I have something like this
August, 2015 July, 2015 September, 2015 How to sort by month, not by alphabetic order?
I tried to add order by date but without any result. And the output format should be exactly like this.
order byto sort in SQL, but you shouldn't sort by your converted value but likely the original valueORDER BY items must appear in the select list if SELECT DISTINCT is specified.