Reputation: 151
i am new to sql journey and got stuck on one query , i want to return employee having salary greater than their manager , only one table is there, there are employee having unique id
click here for my sample database
Upvotes: 1
Views: 88
Reputation: 3833
I can't access your image link, but here is a simple example:
SELECT emp.name
FROM employee emp
INNER JOIN employee mgr ON emp.managerid = mgr.id AND emp.salary > mgr.salary
Upvotes: 1
Reputation: 1270401
I would do this as:
select e.*
from employees e
where e.salary > (select m.salary
from employees m
where m.id = e.employee_id
);
Upvotes: 1