query-989d5d3482652169f5da43e55dc9cb60

rq turtle/ttl

Ambassadors who were also MPs

select distinct ?person ?personLabel ?birthyear ?deathyear where { ?person p:P39 ?positionStatement . ?positionStatement ps:P39 ?position . { ?position wdt:P31 wd:Q18115939 . } union { ?position wdt:P31 wd:Q56760832 } . # person held a position as UK Ambassador or UK High Commissioner ?person p:P39 ?positionStatement2 . ?positionStatement2 ps:P39 ?position2 . { ?position2 wdt:P279 wd:Q16707842 . } union { ?position wdt:P279 wd:Q18015642 } union { ?position wdt:P279* wd:Q18018860 } # person held a position as a UK, GB, or English MP (breakpoints at 1707 and 1801) optional { ?person wdt:P569 ?born . bind(year(?born) as ?birthyear) } . optional { ?person wdt:P570 ?died . bind(year(?died) as ?deathyear) } .

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 p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
# Ambassadors who were also MPs

select distinct ?person ?personLabel ?birthyear ?deathyear where
{
  ?person p:P39 ?positionStatement . ?positionStatement ps:P39 ?position .
  { ?position wdt:P31 wd:Q18115939 . } union { ?position wdt:P31 wd:Q56760832 } . 
  # person held a position as UK Ambassador or UK High Commissioner
  ?person p:P39 ?positionStatement2 . ?positionStatement2 ps:P39 ?position2 . 
  { ?position2 wdt:P279* wd:Q16707842 . } union { ?position wdt:P279* wd:Q18015642 }  union { ?position wdt:P279* wd:Q18018860 }
  # person held a position as a UK, GB, or English MP (breakpoints at 1707 and 1801)
  optional { ?person wdt:P569 ?born . bind(year(?born) as ?birthyear) } .
  optional { ?person wdt:P570 ?died . bind(year(?died) as ?deathyear) } .

  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; v7("?birthyear"):::projected v6("?born") v9("?deathyear"):::projected v8("?died") v1("?person"):::projected v3("?position") v5("?position2") v2("?positionStatement") v4("?positionStatement2") c4(["wd:Q18115939"]):::iri c5(["wd:Q56760832"]):::iri c9(["wd:Q18018860"]):::iri c7(["wd:Q16707842"]):::iri c13(["bd:serviceParam"]):::iri c15(["#91;AUTO_LANGUAGE#93;,en"]):::literal c8(["wd:Q18015642"]):::iri v1 --"p:P39"--> v2 v2 --"p:statement/P39"--> v3 subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; v3 --"p:direct/P31"--> c5 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v3 --"p:direct/P31"--> c4 end union0r <== or ==> union0l end v1 --"p:P39"--> v4 v4 --"p:statement/P39"--> v5 subgraph union1[" Union "] subgraph union1l[" "] style union1l fill:#abf,stroke-dasharray: 3 3; subgraph union2[" Union "] subgraph union2l[" "] style union2l fill:#abf,stroke-dasharray: 3 3; v3 --"p:direct/P279"--> c9 end subgraph union2r[" "] style union2r fill:#abf,stroke-dasharray: 3 3; v3 --"p:direct/P279"--> c8 end union2r <== or ==> union2l end end subgraph union1r[" "] style union1r fill:#abf,stroke-dasharray: 3 3; v5 --"p:direct/P279"--> c7 end union1r <== or ==> union1l end subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v1 -."p:direct/P569".-> v6 bind0[/"year-from-dateTime(?born)"/] v6 --o bind0 bind0 --as--o v7 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v1 -."p:direct/P570".-> v8 bind1[/"year-from-dateTime(?died)"/] v8 --o bind1 bind1 --as--o v9 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c13 --"wikibase:language"--> c15 end