Hi,
I have this two tables:
TABLE1 TABLE2
-- --
A A
B B
C D
D
E
I want my result to be
A Yes
B Yes
C No
D Yes
E No
Joining both tables, having all the values on the first
one and sort of a flag indicating whether it exists in
the second table or not.
Thanks for your help!Try this:
SELECT TableA.ColA,
CASE WHEN (TableB.ColB IS NULL) THEN 'No'
ELSE 'Yes' END
FROM TableA LEFT OUTER JOIN TableB
ON (TableA.ColA = TableB.ColB)
HTH,
Peter.
>--Original Message--
>Hi,
>I have this two tables:
>TABLE1 TABLE2
>-- --
>A A
>B B
>C D
>D
>E
>I want my result to be
>A Yes
>B Yes
>C No
>D Yes
>E No
>Joining both tables, having all the values on the first
>one and sort of a flag indicating whether it exists in
>the second table or not.
>Thanks for your help!
>.
>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment