Hi,
I am practicing basic SQL skills. I am using hr sample schema. My question is about a simple self join.
1. select count(*) from employees; -- returns 107 rows.
2. select first_name, employee_id, manager_id from employees; -- returns 107 rows with Steven, emp_id 100 and Manager_id null. ( because he is the AD_PRES)
Now instead of manager_id from the above sql, I need their name.
So I did a self join,
3. select e.first_name, e.employee_id, m.manager_name from employees e, employees m where e.manager_id = m.employee_id; -- This returns 106 rows with the exception of Steven, emp_id 100. ( I understand why it is not returned, because the manager_id is null for that row).
But I want that row also, with his manager name something like "No Manager". I tried using NVL function. But it is not working. What am I doing wrong? How can I achieve this?
In short I want 107 rows for the third query. How can I do that?
Thanks,