A DISTINCT clause is used in the select statement to return only the distinct values from a data set.
Consider the employee table as shown below:
I would like to query all the departments from the employee table.
SELECT department FROM employee; department ---------- sales accounts sales sales accounts support support support sales
But what if I would like to return each department name only once ? DISTINCT clause does just that. It removes duplicates from the result set.
SELECT DISTINCT department FROM employee; department ---------- sales accounts support