What is {position held} of {Robert I of Scotland} that is {replaced by} is {David II of Scotland} ?
In Scotland, David the Second took over from Robert the First in what position?
In what role did David the Second of Scotland, replace Robert the First of Scotland?
SELECT ?p WHERE { resource:Robert_I_of_Scotland property:position_held ?f . ?f property:replaced_by resource:David_II_of_Scotland . ?f property:position_held ?p }
select distinct ?obj  where {
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#subject> <http://wikidata.dbpedia.org/resource/Q187312> .
?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/Q239486>
} 

SELECT ?obj WHERE { wd:Q187312 p:P39 ?s . ?s ps:P39 ?obj . ?s pq:P1366 wd:Q239486 }