Kum*_*mar 0 sql oracle ora-00904 rownum
SELECT instmax
FROM
(SELECT instmax ,rownum r
FROM
( SELECT instmax FROM pswlinstmax ORDER BY instmax DESC NULLS LAST
)
WHERE r = 2
);
Run Code Online (Sandbox Code Playgroud)
ORA-00904: "R": invalid identifier
00904. 00000 - "%s: invalid identifier"
*Cause:
*Action:
Error at Line: 39 Column: 8
Run Code Online (Sandbox Code Playgroud)
为什么它会给出这个错误?
小智 6
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;
Run Code Online (Sandbox Code Playgroud)