The outer query retrieves a list of department numbers, and the subquery is then run for each department number to return all names belonging to that department. The subquery uses the FOR XML statement to format the output into a single line comma separated list.