query-13725bbcb8eb7fa66961f61e17e66a3f

rq turtle/ttl

incumbents for a single constituency

here, Edinburgh South

SELECT DISTINCT ?person ?personLabel ?partyLabel ?start ?electionLabel ?end ?causeLabel { ?person p:P39 ?positionStatement . ?positionStatement ps:P39 [wdt:P279* wd:Q16707842] . # all people who held an MP position ?positionStatement pq:P768 wd:Q1070093 . # filter only to those with Edinburgh South as the constituency OPTIONAL { ?positionStatement pq:P4100 ?party . } OPTIONAL { ?positionStatement pq:P580 ?start . } OPTIONAL { ?positionStatement pq:P2715 ?election . } OPTIONAL { ?positionStatement pq:P582 ?end . } OPTIONAL { ?positionStatement pq:P1534 ?cause . } SERVICE wikibase:label { bd:serviceParam wikibase:language 'en' } } ORDER BY ?start

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#>
# incumbents for a single constituency
# here, Edinburgh South
SELECT DISTINCT ?person ?personLabel ?partyLabel ?start ?electionLabel ?end ?causeLabel {
 ?person p:P39 ?positionStatement .
 ?positionStatement ps:P39 [wdt:P279* wd:Q16707842] .  # all people who held an MP position
 ?positionStatement pq:P768 wd:Q1070093 .              # filter only to those with Edinburgh South as the constituency
 OPTIONAL { ?positionStatement pq:P4100 ?party . }
 OPTIONAL { ?positionStatement pq:P580 ?start . }
 OPTIONAL { ?positionStatement pq:P2715 ?election . }
 OPTIONAL { ?positionStatement pq:P582 ?end . }
 OPTIONAL { ?positionStatement pq:P1534 ?cause . }
 SERVICE wikibase:label { bd:serviceParam wikibase:language 'en' }
}
ORDER BY ?start

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v7("?cause") v5("?election") v6("?end"):::projected v4("?party") v2("?person"):::projected v3("?positionStatement") v1("?start"):::projected a1((" ")) c3(["wd:Q16707842"]):::iri c15(["en"]):::literal c6(["wd:Q1070093"]):::iri c13(["bd:serviceParam"]):::iri v2 --"p:P39"--> v3 a1 --"p:direct/P279"--> c3 v3 --"p:statement/P39"--> a1 v3 --"p:qualifier/P768"--> c6 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v3 -."p:qualifier/P4100".-> v4 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v3 -."p:qualifier/P580".-> v1 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v3 -."p:qualifier/P2715".-> v5 end subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v3 -."p:qualifier/P582".-> v6 end subgraph optional4["(optional)"] style optional4 fill:#bbf,stroke-dasharray: 5 5; v3 -."p:qualifier/P1534".-> v7 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c13 --"wikibase:language"--> c15 end