SQL - 在嵌套选择中使用值

Nic*_*ick 5 sql oracle nested

希望标题有某种意义 - 我基本上想根据原始选择中的值进行嵌套选择,如下所示:

SELECT MAX(iteration) AS maxiteration,
       (SELECT column
        FROM   table
        WHERE  id = 223652
               AND iteration = maxiteration)
FROM   table
WHERE  id = 223652;  
Run Code Online (Sandbox Code Playgroud)

我收到 ORA-00904 无效标识符错误。

非常感谢有关如何返回此值的任何建议,谢谢!

Den*_*rdy 3

看起来应该用 where 子句重写:

select iteration,
       col
from tbl
where id = 223652
and iteration = (select max(iteration) from tbl where id = 223652);
Run Code Online (Sandbox Code Playgroud)