case
when (select count(*) from dat2 where fx=f2) > 0 then 'XX'
when (select count(*) from dat3 where fx=f2) > 0 then 'XX'
:
else 'XY'
end as status