例如:
1 23 12
33 AB1 A1
5 AC4 B5
77 AD9 B5
7 93C 1
。
A B C D E F G
1 EA12 B5
2 B29 7
3 AD9 AC4
7 AB1 1
结果
A B C
1 1 23 null 12 null
33 null AB1 AB1 A1 null
5 5 AC4 AC4 B5 B5
77 null AD9 AD9 B5 B5
7 7 93C null 1 1
答案 0 :(得分:1)
我认为这是您所需要的:
with
x as (
select c as v from t2
union select e from t2
union select g from t2
)
select
a,
(case when a in (select v from x) then a end) as found_a,
b,
(case when b in (select v from x) then b end) as found_b,
c,
(case when c in (select v from x) then c end) as found_c
from t1