【问题标题】:How to pass a parameter to a subquery in OracleOracle中如何将参数传递给子查询
【发布时间】:2011-12-09 14:10:42
【问题描述】:

我需要将以下用 SQL-Server 编写的查询转换为 PL / SQL,但我无法将参数传递给子查询。

select 
     p.ID,
     case 
        when p.column1 = 1 
      then (select top 1 sub.column1 from internal sub where sub.Id = p.Id)
     end SubQueryWithParameter
from
     parent

有什么想法吗?

【问题讨论】:

    标签: sql oracle plsql subquery


    【解决方案1】:

    问题出在你的子查询上:

    select top 1 sub.column1 from internal sub where sub.Id = p.Id
    

    也许你想要:

    select sub.column1 from internal sub where sub.Id = p.Id and rownum=1
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-11
      • 2017-03-08
      • 1970-01-01
      • 2013-04-21
      • 1970-01-01
      • 2019-12-09
      相关资源
      最近更新 更多