query-b446af24f83fb8a65c01d155291566de

rq turtle/ttl

title:Indians deceased in 2021 ordered by the number of sitelinks SELECT ?person ?sitelinks ?personLabel ?personDescription ?born ?died ?age WHERE{ ?person wdt:P31 wd:Q5; wdt:P27 wd:Q668; wdt:P569 ?born; wdt:P570 ?died. FILTER ( ?died >= "2021-01-01T00:00:00Z"^^xsd:dateTime && ?died <= "2021-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) ?person wikibase:sitelinks ?sitelinks. SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE], en". } } ORDER BY DESC(?sitelinks)

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#>
#title:Indians deceased in 2021 ordered by the number of sitelinks
SELECT ?person ?sitelinks ?personLabel ?personDescription ?born ?died ?age 
WHERE{
  ?person wdt:P31 wd:Q5;
          wdt:P27 wd:Q668;
          wdt:P569 ?born;
          wdt:P570 ?died.
  FILTER ( ?died >= "2021-01-01T00:00:00Z"^^xsd:dateTime && ?died <= "2021-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)
  ?person wikibase:sitelinks ?sitelinks.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE], en". }
}
ORDER BY DESC(?sitelinks)

Query found at

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