query-8df9c152aa218a1dd8b256f37546e77d

rq turtle/ttl

TODO

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX schema: <http://schema.org/>
PREFIX psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX p: <http://www.wikidata.org/prop/>
SELECT (count(?p) as ?count) (avg(?age) as ?avg_age) WHERE 
{
  ?p wdt:P31 wd:Q5 ;
      p:P569/psv:P569 [wikibase:timeValue ?birth] ;
      p:P570/psv:P570 [wikibase:timeValue ?death] .
      ?article schema:about ?p ; schema:isPartOf <https://en.wikipedia.org/> .
  bind(?death-?birth as ?agedays)
  bind(?agedays/365 as ?age)
  filter(year(?birth) > 1800 && year(?birth) < 1899|| (year(?death) > 1800 && year(?death) < 1899))
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v6("?age"):::projected v5("?agedays") v4("?article") v8("?avg_age") v1("?birth") v7("?count") v2("?death") v3("?p"):::projected a2((" ")) a1((" ")) a4((" ")) a3((" ")) c12([https://en.wikipedia.org/]):::iri c4(["wd:Q5"]):::iri f0[["(year-from-dateTime(?birth) > '1800^^xsd:integer'year-from-dateTime(?birth) < '1899^^xsd:integer' || year-from-dateTime(?death) > '1800^^xsd:integer'year-from-dateTime(?death) < '1899^^xsd:integer')"]] f0 --> v1 f0 --> v2 v3 --"p:direct/P31"--> c4 a1 --"wikibase:timeValue"--> v1 v3 --"p:P569"--> a2 a2 --"p:statement/value/P569"--> a1 a3 --"wikibase:timeValue"--> v2 v3 --"p:P570"--> a4 a4 --"p:statement/value/P570"--> a3 v4 --"schema:about"--> v3 v4 --"schema:isPartOf"--> c12 bind1[/"?death - ?birth"/] v2 --o bind1 v1 --o bind1 bind1 --as--o v5 bind2[/"?agedays / '365^^xsd:integer'"/] v5 --o bind2 bind2 --as--o v6 bind5[/"count(?p)"/] v3 --o bind5 bind5 --as--o v7 bind6[/"average(?age)"/] v6 --o bind6 bind6 --as--o v8