GordonPrince
asked on
return Y or N based on result of EXISTS subquery
What would be a good way to make this logic work in a SQL query?
select col1, col2, col3, YorN
from tab1
I want to return YorN as either a literal 'Y' or 'N' based on whether or not something EXISTS or not.
if EXISTS (select 1 from tab2 where tab1.col1 = tab2.col1) then Y
if NOT EXISTS (same as above) then select N
What's the most efficient way of doing this?
select col1, col2, col3, YorN
from tab1
I want to return YorN as either a literal 'Y' or 'N' based on whether or not something EXISTS or not.
if EXISTS (select 1 from tab2 where tab1.col1 = tab2.col1) then Y
if NOT EXISTS (same as above) then select N
What's the most efficient way of doing this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Lee
Open in new window