SQL

SQL

Made by DeepSource

Ambiguous use of DISTINCT SQL-L021

Anti-pattern
Major

Ambiguous use of DISTINCT in select statement with GROUP BY.

Bad practice

DISTINCT and GROUP BY are conflicting.

SELECT DISTINCT
    a
FROM foo
GROUP BY a

Recommended

Remove DISTINCT or GROUP BY. In this case, removing GROUP BY is better.

SELECT DISTINCT
    a
FROM foo