SQL DISTINCT Is Not a Function

A very common misconception I often encounter with SQL users is the idea that DISTINCT is something like a function, and that it can take parenthesised arguments. Just recently, I’ve seen this Stack Overflow question where the OP was looking for a way to express this in jOOQ:

SQL
 




x


1
SELECT DISTINCT (emp.id), emp.fname, emp.name
2
FROM employee emp;