Write a postgre sql query to make a join with two tables employees and departments to display the department ID, department name and the first name of the manager
Write a postgre sql query to make a join with two tables employees and departments to display the department ID, department name and the first name of the manager.
Sample table: employees
Output:
pg_exercises=# SELECT w1.department_id, w1.department_name, w2.manager_id, w2.first_name pg_exercises-# FROM departments w1 pg_exercises-# INNER JOIN employees w2 pg_exercises-# ON (w1.manager_id = w2.employee_id); department_id | department_name | manager_id | first_name ---------------+------------------+------------+------------ 60 | IT | 102 | Alexander 30 | Purchasing | 100 | Den 90 | Executive | 0 | Steven 80 | Sales | 100 | John 50 | Shipping | 100 | Adam 100 | Finance | 101 | Nancy 10 | Administration | 101 | Jennifer 20 | Marketing | 100 | Michael 40 | Human Resources | 101 | Susan 70 | Public Relations | 101 | Hermann 110 | Accounting | 101 | Shelley (11 rows)need an explanation for this answer? contact us directly to get an explanation for this answer