what is the {replaced by} for {John Quincy Adams} has {position held} as {United States senator} ?
Which senator took over from John Quincy Adams as United States senator?
Who replaced John Quincy Adams as United States senator?
SELECT ?d WHERE { resource:John_Quincy_Adams property:position_held ?n . ?n property:position_held resource:United States senator . ?n property:replaced_by ?d }
select distinct ?value  where {
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#subject> <http://wikidata.dbpedia.org/resource/Q11816> .
?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/Q13217683> .
?statement <http://www.wikidata.org/entity/P1366> ?value. 
} 

SELECT ?value WHERE { wd:Q11816 p:P39 ?s . ?s ps:P39 wd:Q13217683 . ?s pq:P1366 ?value}