What is {position held} of {Gregory II} that is {series ordinal} is {89} ?
When he was 89 years old, what position was held by Gregory II?
What position did Gregory II hold when he was 89?
SELECT ?z WHERE { ?p property:position_held ?z . resource:Gregory_II property:position_held ?p . ?p property:series_ordinal ?p . FILTER ( CONTAINS ( ?p , '89' ) ) }
select distinct ?obj  where {
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#subject> <http://wikidata.dbpedia.org/resource/Q103321> .
?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/P1545> <89>
} 

SELECT ?obj WHERE { wd:Q103321 p:P39 ?s . ?s ps:P39 ?obj . ?s pq:P1545 ?x filter(contains(?x , '89')) }