複数のテトラナンバー (1 から n へのマッピング) を持つ custref を返すクエリがあります。
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;