query-eb75e19ae6c4511ff09f836848b296fc

rq turtle/ttl

Propertiesinstance of (P31)date of death (P570)date of birth (P569)

Use at

PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
#defaultView:LineChart
SELECT ?age (COUNT(?person) AS ?count) WHERE {

{
  SELECT DISTINCT * WHERE {
    ?person wdt:P31 wd:Q5.
    ?person wdt:P570 ?dod.
    ?person wdt:P569 ?dob.
    FILTER(YEAR(?dod) > 1900)
    FILTER(?dod > ?dob)
    }
  LIMIT 100000
  }
  BIND(YEAR(?dod)-YEAR(?dob) as ?age)
  FILTER(?age <= 120)
  }
GROUP BY ?age
ORDER BY DESC(?count)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v6("?age"):::projected v6("?count") v4("?dob") v3("?dod") v5("?person"):::projected c4(["wd:Q5"]):::iri f0[["?age <= '120^^xsd:integer'"]] f0 --> v6 f1[["?dod > ?dob"]] f1 --> v3 f1 --> v4 f2[["year-from-dateTime(?dod) > '1900^^xsd:integer'"]] f2 --> v3 v5 --"wdt:P31"--> c4 v5 --"wdt:P570"--> v3 v5 --"wdt:P569"--> v4 bind3[/"year-from-dateTime(?dod) - year-from-dateTime(?dob)"/] v3 --o bind3 v4 --o bind3 bind3 --as--o v6 bind5[/"count(?person)"/] v5 --o bind5 bind5 --as--o v6