what is the {end time} for {Andrew Johnson} has {position held} as {United States senator} ?
In which year did Andrew Johnson retire as a U.S Senator?
At what point did Andrew Johnson end his career as a United States senator?
SELECT ?o WHERE { resource:Andrew_Johnson property:position_held ?b . ?b property:end_time ?o . ?b property:position_held resource:United States senator }
select distinct ?value  where {
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#subject> <http://wikidata.dbpedia.org/resource/Q8612> .
?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/P582> ?value. 
} 

SELECT ?value WHERE { wd:Q8612 p:P39 ?s . ?s ps:P39 wd:Q13217683 . ?s pq:P582 ?value}