You just need to do order by desc with the age predicate and then limit to just get the first one.
PREFIX ns: <http://namespace.org/ontology/> SELECT ?s ?age WHERE { ?s ns:age ?age } ORDER BY DESC(?age) LIMIT 1
See the order by semantics in SPARQL here
In the next version of SPARQL, 1.1, which is already supported on some systems, you can use function aggregates and do.
SELECT max(?age) as ?maxage WHERE { ?s ns:age ?age }
This is currently not supported in all three stores.
source share