【发布时间】:2020-05-05 10:53:19
【问题描述】:
环境:Oracle 12c
我有一个名为:MY_TAB 的表,其中包含以下示例数据:
CODE KEY_ID
------------ --------
2000 95
1055 96
2000 97
使用上面的示例表数据,我需要获取最小 CODE 值,在本例中为 1055 以及 KEY_ID 以及该最小 CODE 值,即 96,并在另一个查询中使用它:
select *
from another_table
where code = minimum CODE value from MY_TAB
and key_id = KEY_ID alongside the minimum CODE value
正在考虑使用这样的东西:
where code = (select min(CODE) from MY_TAB where .....) 1055
and key_id = select KEY_ID from MY_TAB for MIN(CODE) 96
不确定在没有多个嵌套内联选择的情况下处理此查询的最佳方法是什么。
【问题讨论】: