Let's learn Right Outer Join!




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;



Comments

Popular posts from this blog

Let's learn Cross Join!

Full Outer Join!

Let's extract STRING!