What is {position held} of {Mahmud of Ghazni} that is {replaced by} is {Mohammad Ghaznavi} ?
Mahmud of Ghazn held what position, after replacing Nohammad Ghaznavi?
What was the position held by Mahmud of Ghazn after replacing Mohammad Ghaznavi?
SELECT ?n WHERE { ?h property:replaced_by resource:Mohammad_Ghaznavi . ?h property:position_held ?n . resource:Mahmud_of_Ghazni property:position_held ?h }
select distinct ?obj  where {
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#subject> <http://wikidata.dbpedia.org/resource/Q189271> .
?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/Q32627>
} 

SELECT ?obj WHERE { wd:Q189271 p:P39 ?s . ?s ps:P39 ?obj . ?s pq:P1366 wd:Q32627 }