query-b89ae0dc1c3ac58166eaffaedd6997e1

rq turtle/ttl

Wikidata entries for British ambassadors and high commissioners

all people who held at least one such position

one line per position held (so many people appear repeatedly)

start/end dates for that particular position

select ?person ?personLabel ?positionLabel ?startyear ?endyear 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 . bind(year(?start) as ?startyear) } # id start year optional { ?positionStatement pq:P582 ?end . bind(year(?end) as ?endyear) } # id end year SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } }

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#>
# Wikidata entries for British ambassadors and high commissioners
# all people who held at least one such position
# one line per position held (so many people appear repeatedly)
# start/end dates for that particular position

select ?person ?personLabel ?positionLabel ?startyear ?endyear 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 . bind(year(?start) as ?startyear) } # id start year
    optional { ?positionStatement pq:P582 ?end . bind(year(?end) as ?endyear) } # id end year
  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; v6("?end") v7("?endyear"):::projected v2("?person"):::projected v1("?position") v3("?positionStatement") v4("?start") v5("?startyear"):::projected c2(["wd:Q18115939"]):::iri c9(["bd:serviceParam"]):::iri c3(["wd:Q56760832"]):::iri c11(["#91;AUTO_LANGUAGE#93;,en"]):::literal subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; v1 --"p:direct/P31"--> c3 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v1 --"p:direct/P31"--> c2 end union0r <== or ==> union0l end v2 --"p:P39"--> v3 v3 --"p:statement/P39"--> v1 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v3 -."p:qualifier/P580".-> v4 bind0[/"year-from-dateTime(?start)"/] v4 --o bind0 bind0 --as--o v5 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v3 -."p:qualifier/P582".-> v6 bind1[/"year-from-dateTime(?end)"/] v6 --o bind1 bind1 --as--o v7 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c9 --"wikibase:language"--> c11 end