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