what is the {replaced by} for {Joseph Buonaparte.} has {position held} as {King of Spain} ?
Who did Joseph Buonaparte replace as King of Spain?
SELECT ?value WHERE { wd:Q7726 p:P39 ?s . ?s ps:P39 wd:Q3847454 . ?s pq:P1366 ?value}
select distinct ?value  where {
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#subject> <http://wikidata.dbpedia.org/resource/Q7726> .
?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> <http://wikidata.dbpedia.org/resource/Q3847454> .
?statement <http://www.wikidata.org/entity/P1366> ?value. 
} 

Who was King of spain before Joseph Buonaparte?