title: ORACLE SQL: Return Most recently hired employees
body: <p>I am having trouble solving a problem with Oracle SQL. I have to return the most recently hired employees in each department. This would require me to use two tables: DEPARTMENTS and EMPLOYEES. I have to solve this problem without hard coding, meaning I can't use the WHERE clause and I must use a sub query. I must sort the table in ascending order first by department name then employee name. Then end result should resemble this:</p>
  
  <p><a href="https://i.stack.imgur.com/ssOST.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ssOST.png" alt="enter image description here"></a></p>
  
  <p>I thought that an inner join might work and I have this for my code:</p>
  
  <pre><code>     SELECT d1.DEPARTMENT_ID , d1.DEPARTMENT_NAME, 
       e1.EMPLOYEES_ID,e1.EMPLOYEES_NAME, e1.JOB_TITLE, e1.JOB_TITLE
       FROM DEPARTMENTS d1
       INNER JOIN EMPLOYEES e1
       ON d1.DEPARTMENT_ID = e1.DEPARTMENT_ID
       HAVING MAX(e1.HIRE_DATE) = (SELECT e1.HIRE_DATE
                          FROM EMPLOYEES
                          GROUP BY d1.DEPARTMENT_ID)
       ORDER BY d1.DEPARTMENT_NAME, e1.EMPLOYEES_NAME ASC;
  </code></pre>
  
  <p>DEPARTMENTS and EMPLOYEES share DEPARTMENT_ID attribute so I linked them there, but I am unsure of how to get the e1 attributes in the end result. I keep getting a few errors:</p>
  
  <p>not a group by expression
  not a single group function
  too many values</p>
  
  <p>If anyone could explain to me how to approach this problem or what I'm doing wrong, that would be great</p>