query-2d7d58491b3c7b86b266fd0d395300d3
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
- 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 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)