query-67601b8387719490c16aa4d38a5d64bd
TODO
Use at
- https://query.wikidata.org/sparql
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:timePrecision ?tpb ; wikibase:timeValue ?birth] ;
p:P570/psv:P570 [wikibase:timePrecision ?tpd ; wikibase:timeValue ?death] .
?article schema:about ?p ; schema:isPartOf <https://en.wikipedia.org/> .
filter(?tpb>8 && ?tpb<12)
filter(?tpd>8 && ?tpd<12)
bind(?death-?birth as ?agedays)
bind(?agedays/365 as ?age)
filter(year(?birth) > 1800 && year(?birth) < 1899) #birth filter
filter(year(?death) > 1800 && year(?death) < 1899) #death filter
# filter(year(?birth) > 1800 && year(?birth) < 1899|| (year(?death) > 1800 && year(?death) < 1899)) #OR filter
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v8("?age"):::projected
v7("?agedays")
v6("?article")
v10("?avg_age")
v2("?birth")
v9("?count")
v1("?death")
v5("?p"):::projected
v4("?tpb")
v3("?tpd")
a2((" "))
a1((" "))
a4((" "))
a3((" "))
c15([https://en.wikipedia.org/]):::iri
c6(["wd:Q5"]):::iri
f0[["year-from-dateTime(?death) > '1800^^xsd:integer'year-from-dateTime(?death) < '1899^^xsd:integer'"]]
f0 --> v1
f1[["year-from-dateTime(?birth) > '1800^^xsd:integer'year-from-dateTime(?birth) < '1899^^xsd:integer'"]]
f1 --> v2
f2[["?tpd > '8^^xsd:integer'?tpd < '12^^xsd:integer'"]]
f2 --> v3
f3[["?tpb > '8^^xsd:integer'?tpb < '12^^xsd:integer'"]]
f3 --> v4
v5 --"p:direct/P31"--> c6
a1 --"wikibase:timePrecision"--> v4
a1 --"wikibase:timeValue"--> v2
v5 --"p:P569"--> a2
a2 --"p:statement/value/P569"--> a1
a3 --"wikibase:timePrecision"--> v3
a3 --"wikibase:timeValue"--> v1
v5 --"p:P570"--> a4
a4 --"p:statement/value/P570"--> a3
v6 --"schema:about"--> v5
v6 --"schema:isPartOf"--> c15
bind4[/"?death - ?birth"/]
v1 --o bind4
v2 --o bind4
bind4 --as--o v7
bind5[/"?agedays / '365^^xsd:integer'"/]
v7 --o bind5
bind5 --as--o v8
bind8[/"count(?p)"/]
v5 --o bind8
bind8 --as--o v9
bind9[/"average(?age)"/]
v8 --o bind9
bind9 --as--o v10