What is {position held} of {Mary McAleese} and {end time}
What position did Mary McAleese have and when did she stop?
What position did Mary McAleese have and when did she stop?
SELECT ?w ?q WHERE { ?g property:end_time ?w . . ?g property:position_held ?q . resource:Mary_McAleese property:position_held ?g }
select distinct ?dataprop1 ?obj where { ?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#subject> <http://wikidata.dbpedia.org/resource/Q174662> . ?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> ?obj . ?statement <http://www.wikidata.org/entity/P580> ?dataprop1 . } 
SELECT ?value1 ?obj WHERE { wd:Q174662 p:P39 ?s . ?s ps:P39 ?obj . ?s pq:P582 ?value1 . }