query-af237abcbecd12d01f744d15b7b8c56c

rq turtle/ttl

Age of peoples born between Jan 1 1900 and Dec 31 1910

Use at

PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
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#>
#defaultView:BarChart
SELECT ?age (COUNT(?age) AS ?count) WHERE{
  ?person wdt:P31 wd:Q5;
          wdt:P569 ?birth;
          wdt:P570 ?death.

  FILTER(("1900-01-01"^^xsd:date <= ?birth) && (?birth < "1910-12-31"^^xsd:dat)).

  BIND((YEAR(?death)) - (YEAR(?birth)) AS ?age)
  FILTER((?age > 10) && (?age < 100))

  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". } 
}
GROUP BY ?age
ORDER BY ?age

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v5("?age"):::projected v2("?birth") v5("?count") v4("?death") v3("?person") c10(["bd:serviceParam"]):::iri c12(["#91;AUTO_LANGUAGE#93;"]):::literal c6(["wd:Q5"]):::iri f0[["?age > '10^^xsd:integer'?age < '100^^xsd:integer'"]] f0 --> v5 f1[["'1900-01-01^^xsd:date' <= ?birth?birth < s1910-12-31^^<http://www.w3.org/2001/XMLSchema#dat>'"]] f1 --> v2 v3 --"wdt:P31"--> c6 v3 --"wdt:P569"--> v2 v3 --"wdt:P570"--> v4 bind2[/"year-from-dateTime(?death) - year-from-dateTime(?birth)"/] v4 --o bind2 v2 --o bind2 bind2 --as--o v5 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c10 --"wikibase:language"--> c12 end bind4[/"count(?age)"/] v5 --o bind4 bind4 --as--o v5