File: Data.xml
1
name 1
2
name 2
3
name 3
File: Query.xquery
let $prods := doc("Data.xml")//car
for $d in distinct-values($prods/@model),
$n in distinct-values($prods[@model = $d]/id)
return
Output: