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
SQL
55 years
5 Answers
2001 views
Great Grand Master 0
Answers ( 5 )
SELECT e1.empname, e1.Salary
FROM Employee e1
INNER JOIN Employee e2 ON e1.Salary = e2.Salary AND e1.empid e2.empid
SELECT e1.empname, e1.Salary
FROM Employee e1
INNER JOIN Employee e2 ON e1.Salary = e2.Salary AND e1.empid e2.empid
select e1.empname, e1.salary from employee e1 inner employee e2 on e1.salary=e2.salary and e1.empid!=e2.empid;
Select e1.empname, e1.salary
from employee e1 JOIN employee e2
on e1.salary=e2.salary and e1.empid e2.empid;
e1.empid NOTEQUALTO e2.empid
/*Not Equal to symbol is not working */ U can use !=
SELECT e1.name FROM Employees e1
inner join Employees e2
on e1.Name != e2.Name
and e1.salary = e2.Salary