In this Leetcode Employees Earning More Than Their Managers problem solution, we have given the Employee table, write a SQL query that finds out employees who earn more than their managers.
Problem solution in Mysql.
SELECT Name Employee FROM Employee a WHERE Salary > (SELECT Salary FROM Employee b WHERE a.ManagerId = b.Id)
Problem solution in Oracle.
select e.name Employee from employee e , employee m where e.managerid = m.id and e.salary > m.salary
Problem solution using Join.
select e1.Name from Employee e1 join Employee e2 on e1.ManagerId = e2.Id and e1.Salary>e2.Salary
0 Comments