Skip to content
Advertisement

How to get the employees with their managers

This is what I want the output to look like:

Here’s what I got:

I can’t find why the manager field is blank.

Here’s the table:

14 rows selected.

Advertisement

Answer

This is a classic self-join, try the following:

And if you want to include the president which has no manager then instead of an inner join use an outer join in Oracle syntax:

Or in ANSI SQL syntax:

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement