我需要连接两个具有相同ID值但记录数不同的表。 这就是我所拥有的:
这是我的语法:
select a.id,
a.event_a,
a.occur_a,
a.site_a,
b.event_b,
b.site_b
from table_1 a
full outer join table_2 b
on a.id=b.id;
答案 0 :(得分:0)
您似乎希望对两个表中的大多数列进行独立排序。
这应该做你想要的:
select a.id, a.event_a, a.occur_a, a.site_a,
b.event_b, b.site_b
from (select a.*, row_number() over (partition by id order by id) as seqnum
from table_1 a
) a full outer join
(select b.*, row_number() over (partition by id order by id) as seqnum
from table_2 b
) b
on a.id = b.id;