title: ORACLE SQL: Show the lowest salary in the department with the highest average salary
body: <p>NOTE, this is a homework question.</p>
  
  <p>Please show the department number and the lowest salary in the department whose average salary is the highest average salary.</p>
  
  <p>This is what I have so far,</p>
  
  <pre><code>SELECT DEPARTMENT_ID, MAX_AVG_SALARY
  FROM
    (SELECT DEPARTMENT_ID, AVG(SALARY) AS MAX_AVG_SALARY
    FROM EMPLOYEES
    GROUP BY DEPARTMENT_ID)
  WHERE MAX_AVG_SALARY =
    (SELECT MAX(MAX_AVG_SALARY)
    FROM
      (SELECT DEPARTMENT_ID,
        AVG(SALARY) AS MAX_AVG_SALARY
      FROM EMPLOYEES
      GROUP BY DEPARTMENT_ID
      ));
  </code></pre>
  
  <p>I can get the department_id with the highest salary, but then how do I find the lowest salary in the same department?</p>
  
  <p>Please help!</p>
  
  <p>Thanks!</p>