query-db82730bfd26c8ad0653e0697ffb4f2a

rq turtle/ttl

QA - No start-date; or end-date before start-date; or no end-date and Ambassador in post since 2012 (i.e. maybe too long?)

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 ?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
    optional {?positionStatement pq:P580 ?start .}  # id start year
    optional {?positionStatement pq:P582 ?end .}   # id end year
    filter(!bound(?start)|| ?end<?start || (!bound(?end) && ?start<2012 )) 
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Query found at

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