For the following data sets (super simplified):
t1
ext_id, tid, aid, aum, actions
z1, 1, a, 100, 100
z2, 1, b, 100, 100
x1, 2, d, 200, 200
x2, 2, e, 200, 200
t2
tid, aid, aum, actions
1, a, 100, 100
1, b, 100, 100
1, c, 100, 100
2, d, 200, 200
2, e, 200, 200
2, f, 200, 200
I would like to match t1
with t2
, and get all data for the rest of the aid
's, that join based on tid
:
ie. output should be:
ext_id, tid, aid, aum, actions
(null), 1, c, 100, 100
(null), 2, f, 200, 200
I tried:
select (null) as ext_id, b.*
from #t1 a
right join #t2 b
on a.tid=b.tid
where a.aid is null
But it looks incorrect.
Thank you