DISTINCT is not a function

There is an astonishingly large number of (SQL) developers who believe that DISTINCT is a function that needs parentheses and applies to a single column.

To make this clear

DISTINCT is not a function.


The DISTINCT keyword always applies to all columns in the SELECT list. Enclosing one of the columns in parentheses won’t change anything in the outcome.

The following statements are 100% identical in what they achieve:

SELECT DISTINCT (c1), c2, c3
FROM some_table;

SELECT DISTINCT c1, (c2), c3
FROM some_table;

SELECT DISTINCT c1, c2, (c3)
FROM some_table;

SELECT DISTINCT c1, c2, c3
FROM some_table;