query-cfbcfa97cd910f6aadcb23c483b582ce

rq turtle/ttl

query for humans with P27 inconsistent with date of birthhi, playing with sparql here -damn it's fun- tried to write this one 'cause Italy before 1861 it's geopolitically crazy. anyway some results are duplciated/triplicated and I think it involves using SELECT DISTINCT but I'm not sure how. also I'd like an opinion on the query itself, are there some fallacies I haven't though of (besides the fact that ctizenship isn't necessarily automatic with place of birth)?

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 ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?human ?humanLabel ?nato ?natoCLabel ?paeseLabel ?inizioPaese ?finePaese?morte ?morteCLabel WHERE {
  ?human wdt:P31 wd:Q5;
         wdt:P27 wd:Q38;
         wdt:P569 ?nato;
         wdt:P19 ?natoC;
         wdt:P570 ?morte;
         wdt:P20 ?morteC.
    ?natoC p:P17 ?statmt.
  ?statmt ps:P17 ?paese.
         ?statmt pq:P580 ?inizioPaese.
         ?statmt pq:P582 ?finePaese
  FILTER ("1946-06-18"^^xsd:date > ?morte) 
  FILTER (year(?inizioPaese) < year(?nato) && year(?nato) < year(?finePaese))
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],it,en". }
  }

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v3("?finePaese"):::projected v5("?human"):::projected v1("?inizioPaese"):::projected v4("?morte"):::projected v7("?morteC") v2("?nato"):::projected v6("?natoC") v9("?paese") v8("?statmt") c17(["#91;AUTO_LANGUAGE#93;,it,en"]):::literal c5(["wd:Q38"]):::iri c15(["bd:serviceParam"]):::iri c3(["wd:Q5"]):::iri f0[["year-from-dateTime(?inizioPaese) < year-from-dateTime(?nato)year-from-dateTime(?nato) < year-from-dateTime(?finePaese)"]] f0 --> v1 f0 --> v2 f0 --> v3 f1[["'1946-06-18^^xsd:date' > ?morte"]] f1 --> v4 v5 --"p:direct/P31"--> c3 v5 --"p:direct/P27"--> c5 v5 --"p:direct/P569"--> v2 v5 --"p:direct/P19"--> v6 v5 --"p:direct/P570"--> v4 v5 --"p:direct/P20"--> v7 v6 --"p:P17"--> v8 v8 --"p:statement/P17"--> v9 v8 --"p:qualifier/P580"--> v1 v8 --"p:qualifier/P582"--> v3 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c15 --"wikibase:language"--> c17 end