Assume in a table, some of the columns may contain duplicate values. This is not a problem; however, sometimes you will want to list only the different (distinct) values in a table.
DISTINCT helps to eliminate duplicates. If a query returns a result that contains duplicate rows, you can remove duplicates to produce a result set in which every row is unique. To do this, include the keyword DISTINCT after SELECT and before the output column list.
SELECT DISTINCT field_name FROM table_name
Consider this below employee table
Now we want to select only the distinct values from the column named “age” from the table above.
We use the following SELECT query:
SELECT DISTINCT age FROM employee;
The result-set look like this