I\'m reading through some old code at work, and have noticed that there are several views with an order by 1
clause. What does this accomplish?
Exampl
As mentioned in other answers ORDER BY 1
orders by the first column.
I came across another example of where you might use it though. We have certain queries which need to be ordered select the same column. You would get a SQL error if ordering by Name
in the below.
SELECT Name, Name FROM Segment ORDER BY 1