Вы можете использовать full join
:
select coalesce(t1.col5, t2.col6, t3.col7) as member,
nvl2(t1.col5, 1, 0) as in_t1,
nvl2(t2.col6, 1, 0) as in_t2,
nvl2(t3.col7, 1, 0) as in_t3
from table_user_1 t1 full join
table_user_2 t2
on t2.col6 = t1.col5 full join
table_user_3 t3
on t3.col7 in (t1.col5, t2.col6);
В качестве альтернативы вы можете использовать group by
и union all
:
select member,
max(t1), max(t2), max(t3)
from ((select col5 as member, 1 as t1, 0 as t2, 0 as t3
from table_user_1
) union all
(select col6, 0 as t1, 1 as t2, 0 as t3
from table_user_2
) union all
(select col7, 0 as t1, 0 as t2, 2 as t3
from table_user_3
)
) x
group by member;