query-9894ddb852d6259f8cb875c14f755511

rq turtle/ttl

TODO

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 ?item ?itemLabel ?positionLabel ?electoral_districtLabel ?start_time ?end_time ?elected_inLabel ?end_causeLabel
WHERE 
{
  values ?item {wd:Q5345819}                  # person you're interested in
  ?item p:P39 ?statement .                    # has a position statement
  ?statement ps:P39 [wdt:P279* wd:Q486839] .  # which is a subclass of MP
  ?statement ps:P39 ?position .               # and this is the specific position
  OPTIONAL { ?statement pq:P768 ?electoral_district . } # might have an electoral district
  OPTIONAL { ?statement pq:P580 ?start_time . }         # and so on for all the other qualifiers 
  OPTIONAL { ?statement pq:P582 ?end_time . }
  OPTIONAL { ?statement pq:P2715 ?elected_in . }
  OPTIONAL { ?statement pq:P1534 ?end_cause . }
  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("?elected_in") v4("?electoral_district") v8("?end_cause") v6("?end_time"):::projected v1("?item"):::projected v3("?position") v5("?start_time"):::projected v2("?statement") a1((" ")) c3(["wd:Q486839"]):::iri c11(["bd:serviceParam"]):::iri c13(["#91;AUTO_LANGUAGE#93;,en"]):::literal bind0[/VALUES ?item/] bind0-->v1 bind00(["wd:Q5345819"]) bind00 --> bind0 v1 --"p:P39"--> v2 a1 --"p:direct/P279"--> c3 v2 --"p:statement/P39"--> a1 v2 --"p:statement/P39"--> v3 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v2 -."p:qualifier/P768".-> v4 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v2 -."p:qualifier/P580".-> v5 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v2 -."p:qualifier/P582".-> v6 end subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v2 -."p:qualifier/P2715".-> v7 end subgraph optional4["(optional)"] style optional4 fill:#bbf,stroke-dasharray: 5 5; v2 -."p:qualifier/P1534".-> v8 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c11 --"wikibase:language"--> c13 end