could '2' be a column name?
... meaning 'order by 2' would order it by the values in the column named '2', but which wasn't selected.
... meaning 'order by 2' would order it by the values in the column named '2', but which wasn't selected.
SELECT 'val' AS 2
Instead you must escape the identifier with double quotes: SELECT 'val' AS "2"
So there is no ambiguity on that front in the ORDER BY clause. Either you have `ORDER BY 2`, which means order by the second column, or you have `ORDER BY "2"`, which means order by the column named "2".