query-2d7d58491b3c7b86b266fd0d395300d3

rq turtle/ttl

good query to check errors.

provides the difference (in days) between obituary publication date and death date (can be filtered against a given value).

SELECT ?q ?qLabel ?death_date ?obi_date ?diff ?obituary ?obituaryLabel WHERE { ?q wdt:P31 wd:Q5 ; wdt:P1343 ?obituary . ?obituary wdt:P31 wd:Q309481 ; wdt:P1433 wd:Q9684 . ?obituary wdt:P577 ?obi_date . OPTIONAL { ?q wdt:P570 ?death_date } .

FILTER(BOUND(?death_date)) . # FILTER(!BOUND(?death_date)) will filter only the ones who have no date of death

?obituary rdfs:label ?label .
FILTER(!STRSTARTS(?label, "Overlooked") ) . # this is because there's an obituary's series called "Overlooked No More" about past personalities.

BIND((?obi_date - ?death_date) as ?diff).

SERVICE wikibase:label { bd:serviceParam wikibase:language "en,fr". } } GROUP BY ?q ?qLabel ?death_date ?obi_date ?diff ?obituary ?obituaryLabel ORDER BY DESC(?diff)

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>
# good query to check errors. 
# provides the difference (in days) between obituary publication date and death date (can be filtered against a given value).
SELECT ?q ?qLabel ?death_date ?obi_date ?diff ?obituary ?obituaryLabel  WHERE {
  ?q wdt:P31 wd:Q5 ; wdt:P1343 ?obituary .
  ?obituary wdt:P31 wd:Q309481 ; wdt:P1433 wd:Q9684 .
  ?obituary wdt:P577 ?obi_date .
  OPTIONAL { ?q wdt:P570 ?death_date } .

  FILTER(BOUND(?death_date)) . # FILTER(!BOUND(?death_date)) will filter only the ones who have no date of death 

  ?obituary rdfs:label ?label .  
  FILTER(!STRSTARTS(?label, "Overlooked") ) . # this is because there's an obituary's series called "Overlooked No More" about past personalities.

  BIND((?obi_date - ?death_date) as ?diff).

  SERVICE wikibase:label { bd:serviceParam wikibase:language "en,fr". }
}
GROUP BY ?q ?qLabel ?death_date ?obi_date ?diff ?obituary ?obituaryLabel
ORDER BY DESC(?diff)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v3("?death_date"):::projected v7("?diff"):::projected v2("?label") v6("?obi_date"):::projected v5("?obituary"):::projected v4("?q"):::projected c5(["wd:Q309481"]):::iri c14(["en,fr"]):::literal c7(["wd:Q9684"]):::iri c12(["bd:serviceParam"]):::iri c3(["wd:Q5"]):::iri f0[["not starts-with(?label,'Overlooked')"]] f0 --> v2 f1[["bound(?death_date)"]] f1 --> v3 v4 --"wdt:P31"--> c3 v4 --"wdt:P1343"--> v5 v5 --"wdt:P31"--> c5 v5 --"wdt:P1433"--> c7 v5 --"wdt:P577"--> v6 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v4 -."wdt:P570".-> v3 end v5 --"rdfs:label"--> v2 bind2[/"?obi_date - ?death_date"/] v6 --o bind2 v3 --o bind2 bind2 --as--o v7 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c12 --"wikibase:language"--> c14 end