G-3180: Always specify column names instead of positional references in ORDER BY clauses.

Major

Changeability, Reliability

Reason

If you change your select list afterwards the ORDER BY will still work but order your rows differently, when not changing the positional number. Furthermore, it is not comfortable to the readers of the code, if they have to count the columns in the SELECT list to know the way the result is ordered.

Example (bad)

SELECT UPPER(first_name) 
      ,last_name 
      ,salary 
      ,hire_date 
  FROM employees
 ORDER BY 4,1,3;

Example (good)

SELECT upper(first_name) AS first_name  
      ,last_name 
      ,salary 
      ,hire_date
  FROM employees
 ORDER BY hire_date 
         ,first_name 
         ,salary;