Hi I’m currently learning self joins and I’ve got correct query and correct results but I don’t understand certain parts.
Firstly here is my table:
I’m using the self join to give me the name of the person that reports to a higher ranked person. Based on role and report to. So for example Grant would report to Daniel because supervisor answers to manager.
here’s my query:
SELECT m.Name AS ‘manager’,
e.Name AS ‘direct root’
FROM
customer e
INNER JOIN
customer m ON m.cust_id = e.ReportsTo
ORDER BY manager
ASC
The results are :
The part I’m struggling to workout is how the second column is shown. For example I can’t workout how grant is displayed for daniel. Its correct but I just can’see how it gets to it?