Last updated
SQL SELECT DISTINCT
Definition: SELECT DISTINCT returns only different (unique) values, removing duplicates from the result.
Example 1 — with duplicates
Several customers share a country, so this repeats values:
SELECT Country FROM Customers;
Example 2 — each country once
SELECT DISTINCT Country FROM Customers;
Example 3 — count the unique values
SELECT COUNT(DISTINCT Country) FROM Customers;
This tells you how many different countries appear.
💡 When to use: reach for DISTINCT whenever you want a list of the unique options in a column — countries, categories, statuses, and so on.
Try it Yourself
Output
Ad · responsive