SQL Test Question Doesn't Make Sense...?

Hey. I'm totally new to SQL and I'm trying to get certified. I'm on a test now and the question doesn't appear to make any sense:

"Retrieve a list with the managers last name, and the last name of the employees who report to him or her."

The Tables referenced are:

Obviously I can go anywhere and find the answer, but I'm trying to understand this one.

The answer is supposedly:

select a.LastName as EmployeeLast,a.ReportsTo,b.LastName as ManagerLast
from Employees as a
left join Employees as b
on a.ReportsTo=b.EmployeeId
where b.LastName like "Mitchell"

My question is, there is only an Employees table. There is only a "Reports to" column in that table. So how the heck are they pulling this information to get the answer? How does it make sense?

My best guess is the "Reports to" is some sort of code that is able to link the last name to a manager position... but still, how do they expect totally new people to understand that?

I didn't think learning SQL would be easy, but I was hoping these online courses on Coursera would be a bit more helpful in explaining SQL... so far I've learned more about it just freely researching it all myself.

Thanks for any insight!

ReportsTo is an employee id (makes sense: presumably an employee would only report to another employee). Therefore, you can link back to the Employees table based on the ReportsTo to get the last name of the employee they're reporting to.


hope this helps


I have to ask... are the answers for this question in a "multiple-choice" format where there are multiple snippets of code to chose from?

As a bit of a learning sidebar, do you know what the name of any join where both sides of the join refer to the same table?