Tables should not be aliased if that alias is not used. An usused alias makes code harder to read without changing any functionality.
Table aliases should be unique within each clause. It is recommended to name the aliases differently.
It is recommended to use explicit AS
clause for column expressions.
DISTINCT
with parenthesis SQL-L015Parenthesis are not needed and confuse DISTINCT
with a function. The parethesis can also be misleading in which columns they apply to.
DISTINCT
SQL-L021Ambiguous use of DISTINCT
in select statement with GROUP BY
.
JOIN
SQL-L042JOIN
clauses should not contain subqueries. Use Common Table Expression(CTE, aka WITH statement)s instead.
CASE
statements in ELSE
clause SQL-L058Nested CASE
statement in ELSE
clause could be flattened.
Queries that produce an unknown number of result columns are an anti-pattern.