Since you have only pseudo-code that I cannot parse, I am not able to completely follow the logic. With my limited understanding, something like this may be what you need: SELECT
COALESCE(t1.A,t2.A) AS A,
COALESCE(t1.B,t2.B) AS B,
COALESCE(t1.C,t2.C) AS C,
CASE WHEN t1.A IS NOT NULL THEN 'Yes' ELSE 'No' END AS Exists_In_V,
CASE WHEN t2.X IS NOT NULL THEN 'Yes' ELSE 'No' END AS Exists_As_C
FROM
someTable t1
FULL JOIN someTable t2 ON
.....