Duplicate table aliasesSQL-L020Unused table aliasSQL-L025Undefined reference detectedSQL-L026Unqualified referencesSQL-L027Keyword used as an identifierSQL-L029Inconsistent capitalization detectedSQL-L014Inconsistent capitalisation of keywordsSQL-L010Implicit aliasing of table detectedSQL-L011Implicit aliasing of column detectedSQL-L012Column expression without alias detectedSQL-L013`DISTINCT` with parenthesisSQL-L015Ambiguous use of `DISTINCT`SQL-L021Trailing commas within `SELECT` clauseSQL-L038Unnecessary whitespace foundSQL-L039Inconsistent referencesSQL-L028Unnecessary trailing whitespaceSQL-L001Mixed Tabs and Spaces in single whitespaceSQL-L002Expected a single whitespace after `AS`SQL-L023Expected a single whitespace after `USING`SQL-L024Files must end with a trailing newlineSQL-L009Line too longSQL-L016Inconsistent function namesSQL-L030Indentation not consistent with previous linesSQL-L003Operators placed before the newlineSQL-L007Missing whitespace after a commaSQL-L008Function name not immediately followed by bracketSQL-L017Misaligned closing bracketSQL-L018Mixed comma style foundSQL-L019Missing blank lineSQL-L022Mixed Tab and Space indentationSQL-L004Multiple whitespaces around an operatorsSQL-L006Commas has whitespace directly before themSQL-L005Inconsistent capitalisation of boolean or null literalSQL-L040Misaligned `SELECT` modifierSQL-L041Table aliasing in `FROM` and `JOIN` operatorsSQL-L031Confusing use of `USING` operatorSQL-L032File start with ' ' or other whitespaceSQL-L050Unqualified use of `JOIN` clauseSQL-L051Subquery found in `JOIN`SQL-L042Unidiomatic `NULL` checksSQL-L049Unflattened `CASE` statements in `ELSE` clauseSQL-L058Multiple `SELECT` targets on same lineSQL-L036Ambiguous ordering directions for columns in `ORDER BY` clauseSQL-L037Unidiomatic use of `UNION` operatorSQL-L033Unidiomatic `SELECT` operand arrangementSQL-L034Redundant `ELSE NULL`SQL-L035Unnecessary `CASE` statementSQL-L043Unknown number of resulting columnsSQL-L044Unused Common Table Expression in querySQL-L045Use of non-ANSI spec syntax for `COUNT` all rowsSQL-L047Inconsistent styling around string literalsSQL-L048Improperly placed semi-colon(`;`) at statement endSQL-L052Use of brackets wrapping top-level codeSQL-L053Inconsistent column references in `GROUP BY`/`ORDER BY`SQL-L054Use `LEFT JOIN` instead of `RIGHT JOIN`SQL-L055
SQL logoSQL/
SQL-L054

Inconsistent column references in `GROUP BY`/`ORDER BY`SQL-L054

Minor severityMinor
Style categoryStyle

This error occurs when some of the columns in GROUP BY/ORDER BY clauses are prefixed with table names or aliases, while others are not.

SELECT t1.col1, t2.col2
FROM table1 AS t1
JOIN table2 AS t2 ON t1.id = t2.id
GROUP BY col1, t2.col2;

In this query, col1 is unqualified, while t2.col2 is qualified with an alias. This can make the query unclear and inconsistent. SQL lint will suggest using either fully qualified or unqualified column names throughout the query.

Bad practice

A mix of implicit and explicit column references are used in a GROUP BY clause.

SELECT
    foo,
    bar,
    sum(baz) AS sum_value
FROM fake_table
GROUP BY
    foo, 2;

-- The same also applies to column
-- references in ORDER BY clauses.

SELECT
    foo,
    bar
FROM fake_table
ORDER BY
    1, bar;
-- GROUP BY: Explicit
SELECT
    foo,
    bar,
    sum(baz) AS sum_value
FROM fake_table
GROUP BY
    foo, bar;

-- ORDER BY: Explicit
SELECT
    foo,
    bar
FROM fake_table
ORDER BY
    foo, bar;

-- GROUP BY: Implicit
SELECT
    foo,
    bar,
    sum(baz) AS sum_value
FROM fake_table
GROUP BY
    1, 2;

-- ORDER BY: Implicit
SELECT
    foo,
    bar
FROM fake_table
ORDER BY
    1, 2;