I am on the lesson
Intermediate Joins in SQL and screen # 5
Self-Joins, where I need to write queries about
employee name and title and
supervisor name and title.
My confusion is that I don’t see any column in the
employee table that represents the supervisor’s first and last name and the title. But, running the query displays the information about the supervisor. How is it possible?
Here’s the query:
SELECT e1.first_name || " " || e1.last_name employee_name, e1.title employee_title, e2.first_name || " " || e2.last_name supervisor_name, e2.title supervisor_title FROM employee e1 LEFT JOIN employee e2 ON e1.reports_to = e2.employee_id ORDER BY 1;
Thanks for your time.