Yo no uso Oracle, pero creo que tengo una idea.
Prueba ha cambiar el where rnwhere rn
por where rownumwhere rownum
, asi:
SELECT EMPNO, ENAME, HIREDATE, DEPTNO, ROWNUM AS rn FROM (SELECT EMPNO, ENAME, HIREDATE, DEPTNO FROM EMP ORDER BY HIREDATE DESC) WHERE ROWNUM < 3
SELECT EMPNO, ENAME, HIREDATE, DEPTNO, ROWNUM AS rn
FROM (SELECT EMPNO, ENAME, HIREDATE, DEPTNO FROM EMP ORDER BY HIREDATE DESC)
WHERE ROWNUM < 3
Si no te funciona, puedes probar esta otra solución, que consiste en envolver toda la consulta en otra, asi:
Select EMPNO, ENAME, HIREDATE, DEPTNO, rn from ( SELECT EMPNO, ENAME, HIREDATE, DEPTNO, ROWNUM AS rn FROM (SELECT EMPNO, ENAME, HIREDATE, DEPTNO FROM EMP ORDER BY HIREDATE DESC) ) WHERE rn < 3
Select EMPNO, ENAME, HIREDATE, DEPTNO, rn from
(
SELECT EMPNO, ENAME, HIREDATE, DEPTNO, ROWNUM AS rn
FROM (SELECT EMPNO, ENAME, HIREDATE, DEPTNO FROM EMP ORDER BY HIREDATE DESC)
)
WHERE rn < 3