SELECT DISTINCT and ORDER BY
Wednesday, June 24th, 2009ORDER BY items must appear in the select list if SELECT DISTINCT is specified. Recently discovered the above error (T-SQL, SQL Server) when trying to select DISTINCT rows for one set of columns while ordering the rows by another column. Jeff Smith had a good explanation of why this occurs (article). In ...