The DISTINCT keyword removes duplicate rows from the result set. By default query return all the records including duplicates. Duplicate rows can be eliminated by using DISTINCT keyword in the SELECT statement.
SQL SELECT DISTINCT Syntax:
SELECT DISTINCT column_name,column_name FROM table_name;
In this tutorial we will use the well-known pubs sample database.
Below is a selection from the "publishers" table:
The following example lists all the unique countries from the publishers table.
Example: select distinct country from publishers