What is {shares border with} of {Andorra} that is {statement is subject of} is {Andorra–France border} ?
Which country shares the Andorra-France border?
Which country shares its border with Andorra which is named Andorra-France border?
SELECT ?a WHERE { resource:Andorra property:shares_border_with ?d . ?d property:shares_border_with ?a . ?d property:statement_is_subject_of resource:Andorra–France_border }
select distinct ?obj  where {
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#subject> <http://wikidata.dbpedia.org/resource/Q228> .
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate> <http://www.wikidata.org/entity/P47> .
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#object> ?obj .
?statement <http://www.wikidata.org/entity/P805> <http://wikidata.dbpedia.org/resource/Q2009420>
} 

SELECT ?obj WHERE { wd:Q228 p:P47 ?s . ?s ps:P47 ?obj . ?s pq:P805 wd:Q2009420 }