query-1ff0641aa7c32489bf687ce0094fa6f9
Query
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 psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX p: <http://www.wikidata.org/prop/>
#defaultView:LineChart
SELECT ?age (COUNT (DISTINCT ?a) AS ?count) WHERE {
?a wdt:P31 wd:Q5 . #instance of human
?a wdt:P509 wd:Q84263196 . #dead because of COVID-19
?a p:P569/psv:P569 ?birth_date_node .
?a p:P570/psv:P570 ?death_date_node .
?birth_date_node wikibase:timeValue ?birth_date .
?death_date_node wikibase:timeValue ?death_date .
BIND(floor((year(?death_date) - year(?birth_date)) / 10) * 10 as ?age) #decades agregate
}
GROUP BY ?age
ORDER BY ?age
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v2("?a"):::projected
v7("?age"):::projected
v5("?birth_date")
v3("?birth_date_node")
v7("?count")
v6("?death_date")
v4("?death_date_node")
a1((" "))
a2((" "))
c4(["wd:Q84263196"]):::iri
c2(["wd:Q5"]):::iri
v2 --"p:direct/P31"--> c2
v2 --"p:direct/P509"--> c4
v2 --"p:P569"--> a1
a1 --"p:statement/value/P569"--> v3
v2 --"p:P570"--> a2
a2 --"p:statement/value/P570"--> v4
v3 --"wikibase:timeValue"--> v5
v4 --"wikibase:timeValue"--> v6
bind0[/"numeric-floor(year-from-dateTime(?death_date) - year-from-dateTime(?birth_date) / '10^^xsd:integer') * '10^^xsd:integer'"/]
v6 --o bind0
v5 --o bind0
bind0 --as--o v7
bind2[/"count(?a)"/]
v2 --o bind2
bind2 --as--o v7