2017-10-10 13 views
0

同じID値でレコード数が異なる2つのテーブルを結合する必要があります。ここ は、私が持っているものである:ここでは同じキー変数でレコード数が異なるテーブルの結合

enter image description here

enter image description here

enter image description here

enter image description here

は私の構文は次のとおりです。

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

2つのテーブルのほとんどの列の独立した順序付けが必要なようです。

これは、あなたが欲しいものを行う必要があります。

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; 
関連する問題