SQL: DISTINCT Clause
The DISTINCT clause allows you to remove duplicates from the result set. The DISTINCT clause can only be used with select statements.
The syntax for the DISTINCT clause is:
SELECT DISTINCT columns
Let's take a look at a very simple example.
SELECT DISTINCT city
This SQL statement would return all unique cities from the suppliers table.
The DISTINCT clause can be used with more than one field.
SELECT DISTINCT city, state
This select statement would return each unique city and state combination. In this case, the distinct applies to each field listed after the DISTINCT keyword.