Msg 169, Level 15, State 1, Line 1
A column has been specified more than once in the order by list. Columns in the order by list must be unique.
This error message appears when a column name in the ORDER BY clause appears more than once.
The T-SQL statement can be parsed, but causes the error at runtime.
Error of the Severity Level 15 are generated by the user and can be fixed by the SQL Server user. Each column name in the ORDER BY clause can appear just once.
All versions of SQL Server
ORDER BY OrderID, OrderID
In the above example the error is raised by the double specification of the OrderID column. This error message also appears when you don’t refer to the actual column name, but rather also when you reference the column by its ordinal position in the SELECT list. So, this SELECT also raises this error:
SELECT *, 1
ORDER BY OrderID, 1
The error is not raised when you give the column an alias in the SELECT list and refer to this alias instead in the ORDER BY clause. The following example does not raise this error:
SELECT *, OrderID AS t
ORDER BY OrderID, t