Один метод - агрегация:
select max(id1) as id1, max(id2) as id2
from ((select t1.id as id1, null as id2 row_number() over (order by id) as seqnum
from t1
) union all
(select null as id1, t2.id row_number() over (order by id) as seqnum
from t2
where t2.id is not null
)
) t
group by seqnum;
Примечание: сюда входят все идентификаторы, даже если одна таблица больше другой. Если вам нужны только строки, в которых оба идентификатора заполнены, join
- это другой метод:
select t1.id as id1, t2.id as as id2
from (select t1.id as id1, null as id2 row_number() over (order by id) as seqnum
from t1
) t1 join
(select null as id1, t2.id row_number() over (order by id) as seqnum
from t2
where t2.id is not null
) t2
on t1.seqnum = t2.seqnum;