What is {position held} of {Juan Carlos I} that is {replaced by} is {Felipe VI of Spain} ?
In what position did Felipe VI of Spain replace Jaun Carlos I?
What was the position held by Juan Carlos I before Felipe VI of Spain replaced him?
SELECT ?l WHERE { ?x property:position_held ?l . ?x property:replaced_by resource:Felipe_VI_of_Spain . resource:Juan_Carlos_I property:position_held ?x }
select distinct ?obj  where {
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#subject> <http://wikidata.dbpedia.org/resource/Q19943> .
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate> <http://www.wikidata.org/entity/P39> .
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#object> ?obj .
?statement <http://www.wikidata.org/entity/P1366> <http://wikidata.dbpedia.org/resource/Q191045>
} 

SELECT ?obj WHERE { wd:Q19943 p:P39 ?s . ?s ps:P39 ?obj . ?s pq:P1366 wd:Q191045 }