title: Select the oldest and the youngest employees in Oracle
body: <p>I would like to select the oldest and the youngest employees in the workplace. The oldest and the youngest refer to their working experience.
  I referred to previous questions with SQL server and modified my code as below, but I had the error: </p>
  
  <blockquote>
    <p>invalid identifier.</p>
  </blockquote>
  
  <p>I wonder would there be any suggestions for me to change my code?</p>
  
  <pre><code> SELECT d.Dtable_name,
          RANK() OVER(ORDER BY SUM(ROUND((SYSDATE - e.hire_date) / 365.24,0)) DESC) AS yrsexperience
     FROM Dtable_department d
     LEFT JOIN Etable_employee e
       ON d.department_id=e.department_id
  WHERE yrsexperience =(SELECT MAX(d.department_name) KEEP(DENSE_RANK FIRST ORDER BY SUM(ROUND((SYSDATE - e.hire_date) / 365.24,0)) DESC) AS yrsexperience) AS Oldest)FROM Etable_employee e)
  
  OR yrsexperience =(SELECT
         MIN(d.department_name) KEEP(DENSE_RANK LAST  ORDER BY SUM(ROUND((SYSDATE - e.hire_date) / 365.24,0)) DESC) AS yrsexperience) AS Youngest
    FROM Etable_employee e)
  
  </code></pre>
  
  <h2>Update</h2>
  
  <p>I edited the code after referring to the answer below, but it threw me the error:</p>
  
  <blockquote>
    <p>FROM is not found where expected.</p>
  </blockquote>