query-eb854acab559651ac2e431d6f3f551eb

rq turtle/ttl

Heads of state by age

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX v: <http://www.wikidata.org/prop/statement/>

SELECT ?headOfState ?headOfStateLabel ((YEAR(NOW())-YEAR(?birthday)) AS ?age) ?birthday ?stateLabel ?sexLabel WHERE {
  ?state wdt:P31 wd:Q3624078
         FILTER NOT EXISTS {?state wdt:P31 wd:Q3024240}
         FILTER NOT EXISTS {?state wdt:P31 wd:Q1145276} .
  ?state wdt:P35 ?headOfState.
  ?headOfState wdt:P569 ?birthday .
  ?headOfState wdt:P21 ?sex

  SERVICE wikibase:label {bd:serviceParam wikibase:language "de"}
}
ORDER BY DESC(?birthday)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v5("?age") v1("?birthday"):::projected v3("?headOfState"):::projected v4("?sex") v2("?state") c3(["wd:Q3024240"]):::iri c11(["de"]):::literal c4(["wd:Q3624078"]):::iri c9(["bd:serviceParam"]):::iri c2(["wd:Q1145276"]):::iri f0[["not "]] subgraph f0e0["Exists Clause"] e0v1 --"p:direct/P31"--> e0c2 e0v1("?state"):::projected e0c2(["wd:Q1145276"]):::iri end f0--EXISTS--> f0e0 f0 --> v2 f0 --> c1 f0 --> c2 v2 --"p:direct/P31"--> c2 f1[["not "]] subgraph f1e1["Exists Clause"] e1v1 --"p:direct/P31"--> e1c2 e1v1("?state"):::projected e1c2(["wd:Q3024240"]):::iri end f1--EXISTS--> f1e1 f1 --> v2 f1 --> c1 f1 --> c3 v2 --"p:direct/P31"--> c3 v2 --"p:direct/P31"--> c4 v2 --"p:direct/P35"--> v3 v3 --"p:direct/P569"--> v1 v3 --"p:direct/P21"--> v4 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c9 --"wikibase:language"--> c11 end bind2[/"year-from-dateTime(NOW()) - year-from-dateTime(?birthday)"/] v1 --o bind2 bind2 --as--o v5