title: ORACLE SQL - Query based on foreign key
body: <p>Heres an example of the tables i need to make a query.</p>
  
  <p>The Offices Table</p>
  
  <pre><code>       ---OFFICES----
  
  OFFICE_ID - DEPARTMENT - EMPLOYEE_ID - MANAGER_ID
  
      1     - ACCOUNTING -    1      -      1 
      2     - ACCOUNTING -    2      -      2
      3     -     IT     -    3      -      3
  </code></pre>
  
  <p>The Employees table</p>
  
  <pre><code>     ---EMPLOYEES---
  
   EMPLOYEE_ID -  NAME - SURNAME
  
       1        - JOHN  - DOE
       2        - JOHN2 - DOE2
       3        - JOHN3 - DOE3
  </code></pre>
  
  <p>The Managers Table</p>
  
  <pre><code>     ---MANAGERS---
  
  MANAGER_ID - NAME   - SURNAME
  
      1     -  JOHN   - JONES
      2     -  GEORGE - GEORG
      3     -  ALEX   - JON
  </code></pre>
  
  <p>I want based on the OFFICES table to make a query and group the employees and managers based on which department they are but i am not sure how. For example :</p>
  
  <pre><code>           ---QUERY RESULTS---
  
  ACCOUNTING    -     IT
  
  JOHN DOE         JOHN3 DOE
  JOHN2 DOE        ALEX JON
  JOHN JONES
  GEORGE GEOGE
  </code></pre>