SELECT instmax
FROM
(SELECT instmax ,rownum r
FROM
( SELECT instmax FROM pswlinstmax ORDER BY instmax DESC NULLS LAST
)
WHERE r = 2
);
ORA-00904: "R": invalid identifier
00904. 00000 - "%s: invalid identifier"
*Cause:
*Action:
Error at Line: 39 Column: 8
why it's giving this error??
Because aliases are not supported in the WHERE clause of the same query. So instead write your query like:
SELECT instmax
FROM
(SELECT instmax ,rownum r
FROM
( SELECT instmax FROM pswlinstmax ORDER BY instmax DESC NULLS LAST
)
) WHERE r = 2;