Coba:
select a.id, a.x as ax, b.x as bx, x.min_abs_diff
from table_a a
join table_b b
on a.id = b.id
join (select a.id, min(abs(a.x - b.x)) as min_abs_diff
from table_a a
join table_b b
on a.id = b.id
group by a.id) x
on x.id = a.id
and abs(a.x - b.x) = x.min_abs_diff
biola:http://sqlfiddle.com/#!15/ab5ae/5/0
Meskipun tidak sesuai dengan output yang Anda harapkan, saya pikir outputnya benar berdasarkan apa yang Anda jelaskan, karena Anda dapat melihat setiap pasangan memiliki perbedaan dengan nilai absolut 1.
Sunting - Coba yang berikut ini, berdasarkan urutan a hingga b:
select *
from (select a.id,
a.x as ax,
b.x as bx,
x.min_abs_diff,
row_number() over(partition by a.id, b.x order by a.id, a.x) as rn
from table_a a
join table_b b
on a.id = b.id
join (select a.id, min(abs(a.x - b.x)) as min_abs_diff
from table_a a
join table_b b
on a.id = b.id
group by a.id) x
on x.id = a.id
and abs(a.x - b.x) = x.min_abs_diff) x
where x.rn = 1
Biola:http://sqlfiddle.com/#!15/ab5ae/19/0