Maybe this one...
SELECT e.deptno, MAX(e.empno) empno, e.dhire
FROM emp e,
(SELECT deptno, MAX(dhire) dhire FROM emp GROUP BY deptno) e1
WHERE e.deptno = e1.deptno
AND e.dhire = e1.dhire
GROUP BY e.deptno, e.dhire;
MAX(e.empno) in the main select is used in case you have more employees hired at the same date, so that the query returns only one of them.
HTH,




Reply With Quote