2011-12-09 108 views
2

我需要將以下用SQL-Server編寫的查詢轉換爲PL/SQL,但我無法將參數傳遞給子查詢。如何將參數傳遞給Oracle中的子查詢

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 

任何想法?

回答

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