我有一个查询,它返回具有多个四数的 custref(1 到 n 映射)
select *
from cdsheader
where custref in(select custref
from(select *
from cdsheader h,custandaddr c
where h.custref = c.cwdocid
and c.addresstype = 'C')
group by custref
having count(distinct( tetranumber )) > 1)
计数 5144
我的目标是将匹配的地址详细信息与上述结果一起提取,但我想我在这里遗漏了一些东西。
就像是...
select a.cworderid,a.cwcreated,a.organisationtype,a.custref,a.tetranumber,
b.buildingname,b.streetname,b.posttown,b.postcode,b.country
from cdsheader a,custandaddr b
where custref in (select custref
from cdsheader h,custandaddr c
where h.custref = c.cwdocid
and c.addresstype = 'C')
group by custref
having count(distinct( tetranumber )) > 1)
order by a.custref,a.tetranumber,a.cworderid;