SQL Interview Questions | Employees with same salary

Question
empid empname managerid deptid Salary
1 Emp1 0 1 6000
2 Emp2 0 5 6000
3 Emp3 1 1 2000
13 Emp13 2 5 2000
11 Emp11 2 1 2000
9 Emp9 1 5 3000
8 Emp8 3 1 3500
7 Emp7 2 5 NULL
3 Emp3 1 1 2000

Can you get the list of employees with the same salary? You just need to focus on a particular section of the table.

(Hint- Try to be specific)

in progress 0
Dhruv2301 4 years 5 Answers 1994 views Great Grand Master 0

Answers ( 5 )

  1. SELECT e1.empname, e1.Salary
    FROM Employee e1
    INNER JOIN Employee e2 ON e1.Salary = e2.Salary AND e1.empid e2.empid

  2. select e1.empname, e1.salary from employee e1 inner employee e2 on e1.salary=e2.salary and e1.empid!=e2.empid;

  3. Select e1.empname, e1.salary
    from employee e1 JOIN employee e2
    on e1.salary=e2.salary and e1.empid e2.empid;

  4. SELECT e1.name FROM Employees e1
    inner join Employees e2
    on e1.Name != e2.Name
    and e1.salary = e2.Salary

Leave an answer

Browse
Browse