Hi,
As in SQL you can perform a self-join on the “customer” doctype. So, you can translate your SQL query into a similar XQuery expression that looks like this:
for $a in input()/customer
for $b in input()/customer
where
$a/surname = $b/surname
and
$a/hose-no = $b/house-no
and
$a/post-code = $b/post-code
and
$a/id != $b/id
return
$a
But probably the following grouping query is more appropriate:
for $a in distinct-values(input()/customer/surname)
for $b in distinct-values(input()/customer/house-no)
for $c in distinct-values(input()/customer/post-code)
let $g := input()/customer[surname = $a and house-no = $b and post-code = $c]
where count($g) > 1
return
<res @surname = “{$a}“ @house-no = “{$b}” @post-code=”{$c}”>
{$g/id}
The query lists you all combinations of surname, house-no and post-code with more than one “customer” element in the doctype.
Best regards,
Thorsten Fiebig
#API-Management#Tamino#webMethods