query-9dafc974ebb4e5b17cc11a082e2577e5

rq turtle/ttl

SPARQL query

Use at

PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
SELECT DISTINCT ?id ?party ?constituency ?constituency_label WHERE { 
    ?id wdt:P31 wd:Q5 ; p:P39 ?ps .
    ?ps ps:P39 wd:Q83438224 . 
    OPTIONAL { ?ps pq:P4100 ?party }
    OPTIONAL { 
      ?ps pq:P768 ?constituency .
      OPTIONAL { ?constituency rdfs:label ?constituency_label FILTER (LANG(?constituency_label) = "en") }
    }
  }
  ORDER BY ?constituency_label

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v5("?constituency"):::projected v1("?constituency_label"):::projected v2("?id"):::projected v4("?party"):::projected v3("?ps") c5(["wd:Q83438224"]):::iri c2(["wd:Q5"]):::iri v2 --"p:direct/P31"--> c2 v2 --"p:P39"--> v3 v3 --"p:statement/P39"--> c5 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/P768".-> v5 subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v5 -."rdfs:label".-> v1 end end