query-6766310e4b06115090c2db06c27cf619

rq turtle/ttl

Wikidata entries for FO & FCO employees who are not British ambassadors and high commissioners select distinct ?person ?personLabel ?birthyear ?deathyear where { values ?employer {wd:Q358834 wd:Q58211956} # Foreign Office or Foreign & Commonwealth Office ?person wdt:P108 ?employer . # FO or FCO employs the person filter not exists {?person p:P39 ?positionStatement . ?positionStatement ps:P39 ?position . ?position wdt:P31 wd:Q56760832 .} # Person not a High Commissioner filter not exists {?person p:P39 ?positionStatement . ?positionStatement ps:P39 ?position . ?position wdt:P31 wd:Q18115939 .} # Person not an ambassador optional { ?person wdt:P569 ?born . bind(year(?born) as ?birthyear) } # birthyear optional { ?person wdt:P570 ?died . bind(year(?died) as ?deathyear) } # deathyear
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } } order by ?personLabel

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 p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
# Wikidata entries for FO & FCO employees who are not British ambassadors and high commissioners
select distinct ?person ?personLabel ?birthyear ?deathyear where
{
  values ?employer {wd:Q358834 wd:Q58211956}              # Foreign Office or Foreign & Commonwealth Office
  ?person wdt:P108 ?employer .                            # FO or FCO employs the person
  filter not exists {?person p:P39 ?positionStatement . 
                     ?positionStatement ps:P39 ?position . 
                     ?position wdt:P31 wd:Q56760832 .}    # Person not a High Commissioner
  filter not exists {?person p:P39 ?positionStatement . 
                     ?positionStatement ps:P39 ?position . 
                     ?position wdt:P31 wd:Q18115939 .}    # Person not an ambassador 
  optional { ?person wdt:P569 ?born . bind(year(?born) as ?birthyear) } # birthyear
  optional { ?person wdt:P570 ?died . bind(year(?died) as ?deathyear) } # deathyear  
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} order by ?personLabel

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v7("?birthyear"):::projected v6("?born") v9("?deathyear"):::projected v8("?died") v5("?employer") v2("?person"):::projected v1("?personLabel"):::projected v4("?position") v3("?positionStatement") c4(["wd:Q18115939"]):::iri c10(["bd:serviceParam"]):::iri c5(["wd:Q56760832"]):::iri c12(["#91;AUTO_LANGUAGE#93;,en"]):::literal f0[["not "]] subgraph f0e0["Exists Clause"] e0v1 --"p:P39"--> e0v2 e0v2 --"p:statement/P39"--> e0v3 e0v3 --"p:direct/P31"--> e0c4 e0v1("?person"):::projected e0v3("?position"):::projected e0v2("?positionStatement"):::projected e0c4(["wd:Q18115939"]):::iri end f0--EXISTS--> f0e0 f0 --> v2 f0 --> c1 f0 --> v3 f0 --> c2 f0 --> v4 f0 --> c3 f0 --> c4 v2 --"p:P39"--> v3 v3 --"p:statement/P39"--> v4 v4 --"p:direct/P31"--> c4 f1[["not "]] subgraph f1e1["Exists Clause"] e1v1 --"p:P39"--> e1v2 e1v2 --"p:statement/P39"--> e1v3 e1v3 --"p:direct/P31"--> e1c4 e1v1("?person"):::projected e1v3("?position"):::projected e1v2("?positionStatement"):::projected e1c4(["wd:Q56760832"]):::iri end f1--EXISTS--> f1e1 f1 --> v2 f1 --> c1 f1 --> v3 f1 --> c2 f1 --> v4 f1 --> c3 f1 --> c5 v2 --"p:P39"--> v3 v3 --"p:statement/P39"--> v4 v4 --"p:direct/P31"--> c5 bind2[/VALUES ?employer/] bind2-->v5 bind20(["wd:Q358834"]) bind20 --> bind2 bind21(["wd:Q58211956"]) bind21 --> bind2 v2 --"p:direct/P108"--> v5 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v2 -."p:direct/P569".-> v6 bind3[/"year-from-dateTime(?born)"/] v6 --o bind3 bind3 --as--o v7 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v2 -."p:direct/P570".-> v8 bind4[/"year-from-dateTime(?died)"/] v8 --o bind4 bind4 --as--o v9 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c10 --"wikibase:language"--> c12 end