Your first query is just looking at ALL employees with offices in the US, not just the managers. Your second query is applying the condition where the MANAGER's department / location is tied to the U.S. Now, the wording of the question COULD be ambiguous on which "who" worked in the U.S... It could be a PERSON works in the U.S., but the manager is based in Canada, but per their sql answer, it is the MANAGER who works in the US.
Now, that being said, I like to do indentation on my queries to see all the pieces of what I'm looking for and how I get from point A - Z along the way. By indenting you see the relationships between the tables. So lets look at this a bit in reverse. You care about managers based out of the US. So, employee -> Department -> Location -> 'US'
Start by thinking of just the MANAGER, you dont need ALL employees (yet)
select distinct Manager_ID from Employees where Manager_ID > 0
Now, take it to the department associated with "US" location
select distinct
e.Manager_ID
from
employees e
JOIN departments d
on e.department_id = d.department_id
JOIN locations l
on d.location_id = l.locationID
AND l.country_id = 'US'
where
e.Manager_id > 0
Now, we have a finite list of distinct managers regardless of how many employees they have assigned to them. So now you can take THIS query as the primary and get any employees associated with them -- regardless of where the employee actually works -- such as remote employee working in different country than the manager.
select
e2.*
from
( select distinct
e.Manager_ID
from
employees e
JOIN departments d
on e.department_id = d.department_id
JOIN locations l
on d.location_id = l.locationID
AND l.country_id = 'US'
where
e.Manager_id > 0 ) JustMgrs
JOIN employees e2
on JustMgrs.Manager_id = e2.manager_id
So, the second query uses the first query as its basis of records. By wrapping that in the from with ( query ) alias, You can test each individual portion of a query and once it works, that can now be applied without a full write of a temporary table. I can just use the "alias" the rest of the way. So the "JustMgr" gives me only the managers ONCE regardless of how many employees. THEN it re-joins back to the employee table FOR THAT Manager who was in the qualified list in the 'US'.
Does that help clarify why? Does this option also help you see how one could partially dissect a question, get one part first, then go to the next.
FEEDBACK / CLARIFICATION
First, I corrected the query trying to add in the last/first name of the manager, that part was incorrect and probably skewed results but now is ok since updated.
To try and clarify on your comment to explain the second part. Think of it this way, do you understand completely the basis of the first query of getting only MANAGERS based in a U.S. location. By doing DISTINCT, you are getting only one instance of a manager no matter how many employees under them. Its like going into a room of all employees of a company and asking all managers to raise their hands and you get a few people. Now you ask them if the work in a US office to come up on stage and even less of those managers. So now you have your finite list.
Now you tell all employees working for one of those managers to come along too. The second query is using the entire first result set of unique managers and pulling only employees associated with them.
When doing queries, you can write one query and make sure everything works and put that into a "from" clause. By wrapping it within parenthesis and putting a result table/alias name, you can now use THAT as if it were an actual table. You can see this as I wrapped ( the entire manager query ) JustMgrs
. So now that is an alias I can use for the join back to employees to only grab those employees under those managers. Does that help?