query-d7fb23022f03e79ea3810d595521e9da

rq turtle/ttl

Odia people (whose spoken/written language is Odia) died in 2020

SOURCE EXAMPLE: https://www.wikidata.org/wiki/Wikidata:SPARQL_tutorial#BIND,_BOUND,_IF

SELECT ?person ?personLabel ?personDescription ?born ?died ?age WHERE{ ?person wdt:P31 wd:Q5; wdt:P1412 wd:Q33810; wdt:P569 ?born; wdt:P570 ?died. FILTER( ?died > ?born ). FILTER ( ?died >= "2020-01-01T00:00:00Z"^^xsd:dateTime && ?died <= "2020-12-31T00:00:00Z"^^xsd:dateTime ) BIND(?died - ?born AS ?ageInDays). BIND(?ageInDays/365.2425 AS ?ageInYears). BIND(FLOOR(?ageInYears) AS ?age). # or, as one expression: #BIND(FLOOR((?died - ?born)/365.2425) AS ?age). # (https://en.wikibooks.org/wiki/SPARQL/Expressions_and_Functions#COUNT,_MIN,_MAX,_AVG_and_SUM) SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE], en". } } ORDER BY DESC(?age)

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#>
# Odia people (whose spoken/written language is Odia) died in 2020
# SOURCE EXAMPLE: https://www.wikidata.org/wiki/Wikidata:SPARQL_tutorial#BIND,_BOUND,_IF
SELECT ?person ?personLabel ?personDescription ?born ?died ?age 
WHERE{
  ?person wdt:P31 wd:Q5;
          wdt:P1412 wd:Q33810;
          wdt:P569 ?born;
          wdt:P570 ?died.
  FILTER( ?died > ?born ).
  FILTER ( ?died >= "2020-01-01T00:00:00Z"^^xsd:dateTime && ?died <= "2020-12-31T00:00:00Z"^^xsd:dateTime )
  BIND(?died - ?born AS ?ageInDays).
  BIND(?ageInDays/365.2425 AS ?ageInYears).
  BIND(FLOOR(?ageInYears) AS ?age).
  # or, as one expression:
  #BIND(FLOOR((?died - ?born)/365.2425) AS ?age).  # (https://en.wikibooks.org/wiki/SPARQL/Expressions_and_Functions#COUNT,_MIN,_MAX,_AVG_and_SUM)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE], en". }
}
ORDER BY DESC(?age)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v7("?age"):::projected v5("?ageInDays") v6("?ageInYears") v3("?born"):::projected v2("?died"):::projected v4("?person"):::projected c10(["bd:serviceParam"]):::iri c4(["wd:Q5"]):::iri c12(["#91;AUTO_LANGUAGE#93;, en"]):::literal c6(["wd:Q33810"]):::iri f0[["?died >= '2020-01-01T00:00:00Z^^xsd:dateTime'?died <= '2020-12-31T00:00:00Z^^xsd:dateTime'"]] f0 --> v2 f1[["?died > ?born"]] f1 --> v2 f1 --> v3 v4 --"wdt:P31"--> c4 v4 --"wdt:P1412"--> c6 v4 --"wdt:P569"--> v3 v4 --"wdt:P570"--> v2 bind2[/"?died - ?born"/] v2 --o bind2 v3 --o bind2 bind2 --as--o v5 bind3[/"?ageInDays / '365.2425^^xsd:decimal'"/] v5 --o bind3 bind3 --as--o v6 bind4[/"numeric-floor(?ageInYears)"/] v6 --o bind4 bind4 --as--o v7 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c10 --"wikibase:language"--> c12 end