DISTINCT — Show Unique Values
In SQL, the DISTINCT keyword is used to return only unique (non-duplicate) values.
This is helpful when you want to see what values exist in a column, without listing the same value multiple times.
Syntax
SELECT DISTINCT column1 FROM table_name;
Example: Unique Departments
SELECT DISTINCT department FROM employees;
This will return a list of unique department values from the employees table — for example, 'HR', 'IT', 'Sales', etc.
Use DISTINCT when you're more interested in what values exist, not how many times they appear.
Advanced: DISTINCT with Multiple Columns
You can also use DISTINCT with more than one column:
SELECT DISTINCT column1, column2 FROM table_name;
This returns only the unique pairs of values from those two columns — meaning it will list each unique combination only once.
Example: Unique Department + Gender Combinations
SELECT DISTINCT department, gender FROM employees;
This gives you all unique combinations of department and gender across the table.