Memra

Removing duplicates with DISTINCT

Get the set of distinct values in a column.

The distinct values

Many books share a genre. To get each genre once, use DISTINCT:

SELECT DISTINCT genre FROM books;

DISTINCT removes duplicate rows from the result. With several columns it dedupes on the whole row — SELECT DISTINCT genre, author_id gives each distinct *pair*.

NORMAL ~/memra/learn/postgresql/distinct utf-8 LF