-2

I have this two tables in the image from a test that I need to solve:

enter image description here

I need to Select a list of employees with the salary greater than their line manager’s (chief’s)

I tryed:

SELECT NAME
FROM Employee, Employee Chief
WHERE Employee.Chief_ID =Chief_ID
AND Employee.SALARY > Chief.SALARY;

But I think the question is incomplete, and It can't return anything can someone suggest another query?

nbk
  • 45,398
  • 8
  • 30
  • 47
  • use a sub-select to gather the salary of the chief - then do the comparison row by row with the employees in the department – Randy Aug 25 '23 at 15:53
  • Chief_ID must be replaced by chief.id as the chief is also an employee, then this will work – nbk Aug 25 '23 at 15:56
  • 1
    **NEVER** use the A,B join syntax. It's been obsolete for **30 years** now. _ALWAYS_ write out "INNER JOIN", "LEFT JOIN", etc. Otherwise, the main issues is the underscore `_` should be a dot `.` the second time you write `Chief_ID` – Joel Coehoorn Aug 25 '23 at 15:56

0 Answers0