query-1aad88f7b4d2a4ad019b065c07dd589a

rq turtle/ttl

Need help adjusting the query you helped me with request works great! However, after testing it with several dates my specs changed a little; could you change the query so that it returns the 'date of death' and its references INSTEAD OF the references belonging to 'manner of death' and 'cause of death'?: this The last query you created in Hi,item manner of death (NO references) item cause of death (NO references) item date of death (including references) item date of birth sitelinks itemDescription itemLabel item ? could you limit the results to humans who have a page on the English (en) WikipediaAnd finally: 08:01, 17 October 2021 (UTC)) talk (Mill 1Although the query has to be simplified I lack the knowledge to do it myself. Thank again, be immune to any rounding errors and will also alert you if the exact day of birth is unknown or missing). If you don't need it, all you have to do is remove "?age" from the third line of the query.should: I adjusted Dipsacus's query to fit your request. It makes a rough attempt to sort by surname but it won't be perfect. I also added a column that calculates the age of the person at death (it Mill 1@ 21:03, 19 October 2021 (UTC)) talk (Mill 1: not to put you under any kind of pressure but I am kind of waiting for an answer in order to be able to continue some activities for Wikipedia. Already lost the weekend. Tagishsimon:, @Dipsacus fullonum@

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 schema: <http://schema.org/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT
  ?item ?itemLabel ?itemDescription ?sl ?dob
  ?dod ?age ?dod_refs ?cod ?mod
WHERE
{

{
  SELECT
    ?item ?dod_stm ?dod ?dod_refs ?cod_stm ?cod (SAMPLE(?modLabel) AS ?mod)
  WHERE
  {

{
  SELECT
    ?item ?dod_stm ?dod ?dod_refs ?cod_stm (SAMPLE(?codLabel) AS ?cod)
  WHERE
  {
    INCLUDE %get_dod_refs
    OPTIONAL
    {
      ?item p:P509 ?cod_stm .
      ?cod_stm ps:P509 ?cod .
    }
    SERVICE wikibase:label
    {
      bd:serviceParam wikibase:language "en" .
      ?cod rdfs:label ?codLabel .
    }
  }
  GROUP BY ?item ?dod_stm ?dod ?dod_refs ?cod_stm
}    OPTIONAL
    {
      ?item p:P1196 ?mod_stm .
      ?mod_stm ps:P1196 ?mod .
    }
    SERVICE wikibase:label
    {
      bd:serviceParam wikibase:language "en" .
      ?mod rdfs:label ?modLabel .
    }
  }
  GROUP BY ?item ?dod_stm ?dod ?dod_refs ?cod_stm ?cod
}  ?item wikibase:sitelinks ?sl .
  ?item ^schema:about [schema:isPartOf <https://en.wikipedia.org/>] .
  OPTIONAL { ?item wdt:P569 ?dob ;
                   p:P569 ?dob_stm .
             ?dob_stm ps:P569 ?dob ;
                      psv:P569 [wikibase:timePrecision ?dob_precision].}
  SERVICE wikibase:label
    {
      bd:serviceParam wikibase:language "en" .
      ?item rdfs:label ?itemLabel .
      ?item schema:description ?itemDescription .
    }
  BIND(REPLACE(?itemLabel, "^.* (?![SJ]r\\.?$)", "") AS ?sortname)
  BIND(IF(BOUND(?dob),IF(?dob_precision>=11,str(if(?dod< strdt(concat(str(year(?dod)),"-",if(strlen(str(month(?dob)))=1,"0",""),str(month(?dob)),"-",if(strlen(str(day(?dob)))=1,"0",""),str(DAY(?dob))),xsd:dateTime),year(?dod)-year(?dob)-1,year(?dod)-year(?dob))),"exact DOB unknown"),"DOB missing") AS ?age)
}
ORDER BY ASC(UCASE(?sortname))

Query found at