what is the {end time} for {William Lamb, 2nd Viscount Melbourne} has {position held} as {Prime Minister of the United Kingdom} ?
When does William Lamb end his position?
What is the end time for william lamb, 2nd viscount melbourne has a position held as a Prime minister of the united Kingtom?
SELECT ?l WHERE { ?v property:position_held resource:Prime_Minister_of_the_United_Kingdom . resource:William_Lamb,_2nd_Viscount_Melbourne property:position_held ?v . ?v property:end_time ?l }
select distinct ?value  where {
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#subject> <http://wikidata.dbpedia.org/resource/Q312567> .
?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/Q14211> .
?statement <http://www.wikidata.org/entity/P582> ?value. 
} 

SELECT ?value WHERE { wd:Q312567 p:P39 ?s . ?s ps:P39 wd:Q14211 . ?s pq:P582 ?value}