Skip to content

Distinct

distinct

removes duplicate tuples for all the selected rows

Distinct On

Postgres specific

SELECT DISTINCT ON (column)
...
ORDER BY (column, column2)
  1. Runs the query
  2. At the end, GROUP BY the ON (col)
  3. Return the first tuple

Last update: 2022-11-04