Developing some code recently for a local intranet application that uses ASP and SQL Server, I came across the following error:
Error Message: A column has been specified more than once in the order by list. Columns in the order by list must be unique.
So basically, if you give SQL Server a query like
SELECT * FROM Example ORDER BY Example_Column1, Example_Column1
you get such a message.
I am wondering, is there any logical reason why SQL Server does not tolerate a column being specified more than once in the ORDER BY clause? I would think that ORDER BY should just obey something like idempotence, so that the above query simply reduces to:
SELECT * FROM Example ORDER BY Example_Column1
This doesn’t happen with MySQL. As well as the above example, I also tried the following in MySQL and it didn’t complain:
SELECT * FROM Example ORDER BY Example_Column1, Example_Column2, Example_Column1