Sorting result by year and month
Posted on 2004-04-17
I Have a simple query that i am running. but i need the results to only show each month only once, this one has stumpted me! :)
I know why it is happening but i cant solve it
SO should i be using a cast command or somthing else to get around this problem?
Below is my query and the result of when it is run.
DATENAME(YEAR,SAIL_DAT) AS SAIL_YEAR,
DATENAME(MONTH,SAIL_DAT) AS SAIL_MONTH
WHERE RES_AGENT_CD = 'PLUMB_N'
GROUP BY DATENAME(YEAR,SAIL_DAT),DATENAME(MONTH,SAIL_DAT),SAIL_DAT
ORDER BY SAIL_DAT