I am faced with this problem and have no idea how to do it. I have the following question. Show the names of all the departments in the company together with the names of their managers. Your query must show all the departments in the company, even if it has no manager.
My problem is that when I ran a query to give me department names only, I got 27 results. However for the managers query there are just 18 results.
I have no idea how to do this. The Queries I used to get this are, for the department names:
--select department_name from departments;
Administration
Marketing
Purchasing
Human Resources
Shipping
IT
Public Relations
Sales
Executive
Finance
Accounting
Treasury
Corporate Tax
Control And Credit
Shareholder Services
Benefits
Manufacturing
Construction
Contracting
Operations
IT Support
NOC
IT Helpdesk
Government Sales
Retail Sales
Recruiting
Payroll
for the second part:
select first_name, last_name, department_name from employees e inner join departments d on
d.department_id=e.department_id where (employee_id in (select manager_id from employees));
first_name last_name department_name
Steven King Executive
Neena Kochhar Executive
Lex De Haan Executive
Alexander Hunold IT
Nancy Greenberg Finance
Den Raphaely Purchasing
Matthew Weiss Shipping
Adam Fripp Shipping
Payam Kaufling Shipping
Shanta Vollman Shipping
Kevin Mourgos Shipping
John Russell Sales
Karen Partners Sales
Alberto Errazuriz Sales
Gerald Cambrault Sales
Eleni Zlotkey Sales
Michael Hartstein Marketing
Shelley Higgins Accounting
the second part returns the departments only with managers.