Posts

Showing posts with the label Right Outer Join

Let's learn Right Outer Join!

Image
RIGHT 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 JOB_HISTORY JH RIGHT OUTER JOIN EMPLOYEES E 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 EMPLOYEES E RIGHT OUTER JOIN DEPARTMENTS D ON D.MANAGER_ID= E.EMPLOYEE_ID;