Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
SELECT distinct Max(CONVERT(VARCHAR,A.ActiveDate,101)) sortdate, CONVERT(VARCHAR,datename(month,A.ActiveDate)) + ' ' + CONVERT(VARCHAR,YEAR(A.ActiveDate)) ActiveDate FROM Articles A, ArticleGroupLink GL WHERE A.ArticleID = GL.ArticleID and GL.GroupID = 44 GROUP BY ActiveDate order by sortdate desc, --CONVERT(VARCHAR,A.ActiveDate,101) desc , CONVERT(VARCHAR,datename(month,A.ActiveDate)) + ' ' + CONVERT(VARCHAR,YEAR(A.ActiveDate)) descI need to get distinct ActiveDate column. Tried to get the max of the sortdate and group by ActiveDate that is not working for me. How can I get this done?
visakh16
Very Important crosS Applying yaK Herder
52326 Posts
Posted - 2008-11-03 : 12:18:18
looks like you need this
SELECT ActiveDate,MAX(sortdate) AS sortdateFROM(SELECT CONVERT(VARCHAR,A.ActiveDate,101) sortdate, CONVERT(VARCHAR,datename(month,A.ActiveDate)) + ' ' + CONVERT(VARCHAR,YEAR(A.ActiveDate)) ActiveDateFROM Articles A,ArticleGroupLink GLWHEREA.ArticleID = GL.ArticleID andGL.GroupID = 44)tGROUP BY ActiveDateorder by sortdate desc