2 ms·
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.
by grecy 7y ago
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.
- benesch 7y agoIn PostgreSQL, the grammar does not permit unquoted identifiers to start with a digit. So this is a syntax error: 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".