PostgreSQL DISTINCT Keyword
The Distinct statement is used to select or fetch only the (different) Distinct data from a database table. There are many duplicate values present in the database table, so Distinct is used to list different values.
DISTINCT Syntax :
The syntax of the DISTINCT statement is −
SELECT DISTINCT column1, column2,.....columnN FROM table_name WHERE [condition]
DISTINCT Example :
Consider the STUDENT table is having the following records
The following is an example, which would fetch DISTINCT NAME record for a STUDENT.
lfcdb=# SELECT DISTINCT name FROM STUDENT;
All the above statements would create the following records in STUDENT table