-
Notifications
You must be signed in to change notification settings - Fork 549
Open
Description
Question:
/*
- DB: Employees
- Table: employees
- Question: Filter employees who have emp_no 110183 as a manager
*/
Answer:
-- Written with JOIN
SELECT e.emp_no, first_name, last_name
FROM employees as e
JOIN dept_emp as de USING (emp_no)
JOIN dept_manager as dm USING (dept_no)
WHERE dm.emp_no = 110183
In this answer, if we write it like that we will see all the employees who are in the department - d003.
In that dep are 2 managers. and emp_no = 110183 was manager only until 1992-03-21.
My resolution to this:
Select * from "public"."employees" as e
join dept_emp as de on de.emp_no = e.emp_no
join dept_manager as d on d.dept_no = de.dept_no
where d.emp_no = 110183 and de.to_date <= '1992-03-21'
.
Let me know if I'm wrong. Thank you
Metadata
Metadata
Assignees
Labels
No labels