Home

Column names should be used in a SQL ORDER BY clause

Rule description

  • Column names should be used in a SQL ORDER BY clause

 

Non-compliant Code Example

SELECT
    NAME,
    ADDRESS,
    CREDIT_LIMIT
FROM
    CUSTOMERS
ORDER BY 10 ASC; --Non compliant code (Order by clause without column names)

Compliant Code Example

SELECT
    NAME,
    ADDRESS,
    CREDIT_LIMIT
FROM
    CUSTOMERS
ORDER BY CREDIT_LIMIT ASC; --Compliant code (Order by clause with column names)
Visual Expert 2020
 VEPLSQLRULE93