what is the {end time} for {Alfonso II of Asturias} has {occupation} as {king of Asturias} ?
When was Alfonso II of Asturias' control of King of Asturias arrived at an end?
When was Alfonso II of Asturias' occupation of King of Asturias came to an end?
SELECT ?p WHERE { ?x property:end_time ?p . resource:Alfonso_II_of_Asturias property:occupation ?x . ?x property:occupation resource:king_of_Asturias }
select distinct ?value  where {
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#subject> <http://wikidata.dbpedia.org/resource/Q360388> .
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate> <http://www.wikidata.org/entity/P106> .
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#object> <http://wikidata.dbpedia.org/resource/Q29051386> .
?statement <http://www.wikidata.org/entity/P582> ?value. 
} 

SELECT ?value WHERE { wd:Q360388 p:P106 ?s . ?s ps:P106 wd:Q29051386 . ?s pq:P582 ?value}