PostgreSQL

PostgreSQL SELECT DISTINCT

Remove duplicate rows from a query result.

Use DISTINCT

SELECT DISTINCT returns one row for each unique combination of selected values.

SELECT DISTINCT year
FROM products
ORDER BY year;

Duplicates are removed after considering all selected columns, so DISTINCT name, year compares both values together.