query-bfee619093ca7be245e0cc483ceae551

rq turtle/ttl

QA - position dates outside person's lifespan

Use at

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 ?person ?personLabel ?positionLabel ?dob ?dod ?start ?end where
{
  { ?position wdt:P31 wd:Q18115939 . } union { ?position wdt:P31 wd:Q56760832 } . # position is UK ambassador or high commissioner
    ?person p:P39 ?positionStatement . ?positionStatement ps:P39 ?position . # find positions they held
    ?positionStatement pq:P580 ?start .  # id start year
    optional {?positionStatement pq:P582 ?end .}   # id end year
    optional {?person wdt:P569 ?dob.}
    optional {?person wdt:P570 ?dod.} 
    filter(bound(?dob) && bound(?start) && ?start<?dob|| bound(?dod) && bound(?end) && ?end>?dod)
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}   # Note - does not deal with date precision

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v1("?dob"):::projected v3("?dod"):::projected v4("?end"):::projected v6("?person"):::projected v5("?position") v7("?positionStatement") v2("?start"):::projected c2(["wd:Q18115939"]):::iri c3(["wd:Q56760832"]):::iri c11(["bd:serviceParam"]):::iri c13(["#91;AUTO_LANGUAGE#93;,en"]):::literal f0[["(bound(?dob)bound(?start)?start < ?dob || bound(?dod)bound(?end)?end > ?dod)"]] f0 --> v1 f0 --> v2 f0 --> v3 f0 --> v4 subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; v5 --"p:direct/P31"--> c3 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v5 --"p:direct/P31"--> c2 end union0r <== or ==> union0l end v6 --"p:P39"--> v7 v7 --"p:statement/P39"--> v5 v7 --"p:qualifier/P580"--> v2 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v7 -."p:qualifier/P582".-> v4 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v6 -."p:direct/P569".-> v1 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v6 -."p:direct/P570".-> v3 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c11 --"wikibase:language"--> c13 end