1

表格1:

onode_c, dnode_c, dist1

表 2:

onode_c, dnode_c, dist2

我需要一个返回的查询

onode_c, dnode_c, dist1, dist2

dist1对于表 1 和表 2 中和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);

上面的查询多次返回相同的记录。

4

3 回答 3

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);
于 2013-03-19T00:21:03.997 回答
0

尝试使用SELECT DISTINCT也许

于 2013-03-19T00:21:24.083 回答
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);
于 2013-03-19T00:23:30.937 回答