Posts

Showing posts with the label Left Outer Join

Let's learn Left Outer Join!

Image
LEFT OUTER JOIN (i) HR Manager wants all the employees’ details regardless of whether they have past Job-history or not. If employee has a job-history then manager also wants job-history details. Manager to data analyst: Bring me the details of employees along with the details of their job history if employee has one. Data analyst runs below query to fetch the required data. SELECT * FROM EMPLOYEES E LEFT OUTER JOIN JOB_HISTORY JH ON E.EMPLOYEE_ID= JH.EMPLOYEE_ID;  (ii) HR manager wants details of departments regardless of department having manager or not. If department has manager then HR manager also wants the details of manager.  Manager to data analyst:  Bring me the details of departments along with the details of manager of the department. Data analyst runs below query to fetch the required data. SELECT * FROM DEPARTMENTS D LEFT OUTER JOIN EMPLOYEES E ON D.MANAGER_ID= E.EMPLOYEE_ID;