SQL Syntax Reference : DISTINCT
 
DISTINCT
Include the DISTINCT keyword in your SELECT statement to remove duplicate values from the result. By using DISTINCT, you can retrieve all unique rows that match the selection.
The following rules apply:
PSQL supports DISTINCT in subqueries.
DISTINCT is ignored if the selection list contains an aggregate. Aggregation already guarantees no duplicate result rows.
Examples
The following statements retrieve all courses taught by faculty ID 111191115. The second statement uses DISTINCT to eliminate rows with duplicate column values.
SELECT c.Name, c.Description
FROM Course c, class cl
WHERE c.name = cl.name AND cl.faculty_id = '111191115';
 
Name Description
======= ==================================================
CHE 203 Chemical Concepts and Properties I
CHE 203 Chemical Concepts and Properties I
CHE 205 Chemical Concepts and Properties II
CHE 205 Chemical Concepts and Properties II
 
 
SELECT DISTINCT c.Name, c.Description
FROM Course c, class cl
WHERE c.name = cl.name AND cl.faculty_id = '111191115';
 
Name Description
======= ==================================================
CHE 203 Chemical Concepts and Properties I
CHE 205 Chemical Concepts and Properties II
Note The following use of DISTINCT is not allowed:
SELECT DISTINCT column1, DISTINCT column2
See Also
SELECT
For other uses of DISTINCT, see DISTINCT in Aggregate Functions.