Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Subquery inside CASE statement

666129Oct 20 2008 — edited Mar 15 2012
I am trying to use a subquery within a Case statement with a 'where' condition that binds to the parent query. Like this:
Select T.idperson , CASE WHEN  T.type = 'C' THEN (SELECT name from Customers where C.idcustomer = T.idperson) 
ELSE
 (SELECT name from Providers where idprovider = T.idperson)
 END Name 
from myTable T 
This works for me in SQL Server but in ORACLE the subquery does not return any rows, i guess its the binding to parent query part. Any thoughts of another way I could get the result I want?

Thanks,

JuanDiego
This post has been answered by Frank Kulash on Oct 20 2008
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 12 2012
Added on Oct 20 2008
11 comments
122,411 views