I have a database with the following data:
Vertex
Country City Hotel
-------------- -------------- ---------------------------
ID Name ID Name ID Name
-------------- -------------- ---------------------------
#16:0 Italia #17:0 Roma #18:0 Residence Barberini
#18:1 Santa Prisca
Edges
In PartOf
--------------- -------------
From To From To
--------------- -------------
#18:0 #16:0 #17:0 #16:0
#18:0 #17:0
#18:1 #17:0
I would like to extract all the hotels in Italy where they can be extracted directly following the edge In or indirectly following the edge PartOf and for each element PartOf another following the edge In.
Basically the result expected is
#18:0 Residence Barberini (direct from Italia)
#18:1 Santa Prisca (traversing Roma)
I used the following query
select distinct(h) from
(select in('in') as h from (traverse in('partOf') from #16:0))
and I get the following results:
#18:0
#18:0, #18:1
How it is possible to retrieve only the distinct Hotels efficiently? The expected result should be
#18:0
#18:1 (instead of #18:0, #18:1)
Thank you!
You can use
select distinct(h) from
(select in('in') as h from (traverse in('partOf') from #16:0) unwind h)