表1:
onode_c, dnode_c, dist1
表2:
onode_c, dnode_c, dist2
我需要一个返回
的查询onode_c, dnode_c, dist1, dist2
表示表1和表2中dist1
和dist2
不匹配的记录
select a.onode_c, a.dnode_c, trunc(a.dist1), trunc(b.dist2)
from table1 a, table2 b
where a.onode_c = b.onode_c and a.dnode_c = b.dnode_c and trunc(a.dist1) != trunc(b.dist2);
上述查询多次返回相同的记录。
答案 0 :(得分:0)
请尝试以下声明:
select a.onode_c, a.dnode_c, trunc(a.dist), trunc(b.dist2) from table1 a
left join table2 b on a.onode_c = b.onode_c and a.dnode_c = b.dnode_c
where trunc(a.dist1) != trunc(b.dist2);
答案 1 :(得分:0)
尝试使用SELECT DISTINCT
或许
答案 2 :(得分:0)
试试这个:
select DISTINCT a.onode_c, a.dnode_c, trunc(a.dist1), trunc(b.dist2)
from table1 a, table2 b
where a.onode_c = b.onode_c and a.dnode_c = b.dnode_c and trunc(a.dist1) != trunc(b.dist2);