create table client_1 (id int, FIO text, dBirth date);
create table client_2 (id int, FIO text, dBirth date);
insert into client_1 values
(100, 'Ivanov', '1990-05-17'),
(101, 'Petrov', null),
(103, 'Simonov', null),
(106, 'Kozlov', '2020-01-01'),
(107, 'Hohlov', '2020-01-01');
insert into client_2 values
(100, 'Ivanov', null),
(101, 'Petrov', '1990-05-17'),
(105, 'Chernov', null),
(106, 'Kozlov', null),
(107, 'Hohlov', '2020-01-01');
select
t1.id,
t1.FIO,
coalesce(t1.dBirth, t2.dBirth) as dBirth
from client_1 t1
left join client_2 t2 using(id)
where t1.dBirth is null or t2.dBirth is null;
select
t1.id,
t1.FIO,
coalesce(t1.dBirth, t2.dBirth) as dBirth
from client_1 t1
full outer join client_2 t2 using(id)
where t1.dBirth is null or t2.dBirth is null;
select
t1.id,
t1.FIO,
coalesce(t1.dBirth, t2.dBirth) as dBirth
from client_1 t1
left join client_2 t2 using(id)
-- where t1.dBirth is null or t2.dBirth is null
union
select
t1.id,
t1.FIO,
coalesce(t1.dBirth, t2.dBirth) as dBirth
from client_2 t1
left join client_1 t2 using(id);
-- where t1.dBirth is null or t2.dBirth is null;
select
t1.id,
t1.FIO,
coalesce(t1.dBirth, t2.dBirth) as dBirth
from client_1 t1
left join client_2 t2 using(id)
where t1.dBirth is null or t2.dBirth is null
union
select
t1.id,
t1.FIO,
coalesce(t1.dBirth, t2.dBirth) as dBirth
from client_2 t1
left join client_1 t2 using(id)
where t1.dBirth is null or t2.dBirth is null;