Thursday, November 10, 2011

Using Orderby clause in Distinct select query


select * from
(
    SELECT DISTINCT CONVERT(varchar, GeneratedDate, 101) AS GeneratedDate
    FROM ProviderProcessGeneratedDate
    -- no need for ORDER BY, it is implicitly performed when DISTINCTing rows
) as y
order by convert(datetime, GeneratedDate) DESC

No comments:

Post a Comment