Martin's statement about GROUP BY is true, although you> can <definitely use the column number instead of the column name in ORDER BY in various versions of SQL (I think TSQL, which is an ISO standard in most basic SQL syntaxes).
But itβs good practice not to use columnar ordinals in ORDER BY statements, even if they really work. What for? If the query is part of a stored process and the table schema is changed by adding a column to the original table (or view), there is no guarantee that the original column ordering will be supported by the change. This would mean that you can order an unintentional and meaningless column, which then breaks your application.
It is much better to use column names rather than ordinals every time (although, like count (*), do not get stuck on it if it asks for special requests for your own use that will never see the light of day in production).
source share