Description
The SQL keyword DISTINCT is used in a SELECT statement, that returns only distinct (or different) values.
- A SELECT statement with the DISTINCT keyword returns only different values.
- A SELECT statement without the DISTINCT keyword returns all the values, including duplicates.
SELECT With DISTINCT
A SELECT statement with the DISTINCT keyword returns only different values.
The below SQL returns different values of the column "country".
SELECT DISTINCT country FROM customers;
SELECT Without DISTINCT
A SELECT statement without the DISTINCT keyword returns all the values, including duplicates.
The below SQL returns all the values of the column "country", including duplicates.
SELECT country FROM customers;