Rule Definition
Improve readability by sorting on column names rather than column numbers. Improve maintainability by making the ORDER BY part independent.
Remediation
Check the statement and if so, replace column numbers with column names.
Violation Code Sample
SELECT first_name, department_name
FROM employees
JOIN departments
ON (employees.manager_id = departments.manager_id
AND employees.department_id = departments.department_id)
ORDER BY 1, 2;
Fixed Code Sample
The following example:
SELECT first_name, department_name
FROM employees
JOIN departments
ON (employees.manager_id = departments.manager_id
AND employees.department_id = departments.department_id)
ORDER BY 1, 2;
should be rewritten as:
SELECT first_name, department_name
FROM employees
JOIN departments
ON (employees.manager_id = departments.manager_id
AND employees.department_id = departments.department_id)
ORDER BY first_name, department_name;
Related Technologies
Technical Criterion
Programming Practices - Unexpected Behavior
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.