我想从两个以上记录的birth_date 相同但person_id 不相等的连接返回结果。我正在使用甲骨文。因此,如果我得到 4 个结果,其中第 1 行和第 2 行具有相同的出生日期和不同的 person_id,则将返回这些行。如果第 3 行和第 4 行具有相同的birth_date 和相同的 person_id,则不会返回这些行。我得到了结果,但我想过滤我们的结果,其中行的birth_date 相等,但 person_id 是 <>。
select t3.field1, t6.field2, t6.field3, t3.field4, t3.field5
from table1 t1
inner join table2 t2 on t1.@matching = t2.@matching
inner join table3 t3 on t3.@matching = t1.@matching
inner join table4 t4 on t4.@matching = t1.@matching
inner join table5 t5 on t5.@matching = t4.@matching
inner join table6 t6 on t6.@matching = t3.@matching
where t1.@requirement = 'xxx'
and t2.@requirement = 'xxx'
and t2.@requirement is null
and t4.@requirement = 'xxx'
and t5.@requirement = 'xxx'
and t1.@requirement ='xxx'
and t5.@requirement is null
order by t1.@field ASC;