distinct keyword is used with
SELECT statement to retrieve unique values from the table.
Distinct removes all the duplicate records while retrieving records from any table in the database.
SELECT DISTINCT column-name FROM table-name;
Consider the following Emp table. As you can see in the table below, there is employee name, along with employee salary and age.
In the table below, multiple employees have the same salary, so we will be using
DISTINCT keyword to list down distinct salary amount, that is currently being paid to the employees.
SELECT DISTINCT salary FROM Emp;
The above query will return only the unique salary from Emp table.