How to select unique records from a table?

The DISTINCT keyword is used in SQL to eliminate duplicate values from the result set of a SELECT statement. When used, it only returns unique, distinct values. For example, if a table contains multiple rows with the same value in a certain column, the DISTINCT keyword will only return a single row with that value.


Employee Table

emp_id emp_name salary dept_id manager_id
E1 Rahul 15000 D1 M1
E2 Manoj 15000 D1 M1
E3 James 55000 D2 M2
E4 Michael 25000 D2 M2
E5 Ali 20000 D10 M3
E6 Robin 35000 D10 M3
SELECT DISTINCT salary,dept_id FROM Employee;


salary dept_id
15000 D1
55000 D2
25000 D2
20000 D10
35000 D10

Code Runner

Copy the below query in the code runner to see the result

SELECT DISTINCT salary,dept_id FROM Employee;