Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 order by help

Author  Topic 

kshitizgp
Starting Member

31 Posts

Posted - 2012-02-22 : 02:51:49
declare @col nvarchar(max)

select @col = COALESCE(@col + ',','')+ QUOTENAME(Datename(month,work_date ))
from form_Details WHERE Work_Date between '2012-01-01' and '2012-03-31'
GROUP BY Datename(month,work_date)
ORDER BY Datename(month,work_date) asc
print @col

WHEN I print@col

i get data as march , january , feb

the correct order must be jan , feb , march

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2012-02-22 : 03:43:07
ORDER BY WorkDate

--
Gail Shaw
SQL Server MVP
Go to Top of Page
   

- Advertisement -