query-6ecd31ce2bcf39ab1fab4545e66e1f8b

rq turtle/ttl

MPs returned for more than one seat at the same election SELECT DISTINCT ?item ?itemLabel ?electionLabel ?constituencyLabel ?constituency2Label { ?item p:P39 ?positionStatement . ?positionStatement ps:P39 ?term . ?positionStatement pq:P768 ?constituency . ?positionStatement pq:P2715 ?election . SERVICE wikibase:label { bd:serviceParam wikibase:language 'en' } ?item p:P39 ?positionStatement2 . ?positionStatement2 ps:P39 ?term2 . ?positionStatement2 pq:P2715 ?election2 . ?positionStatement2 pq:P768 ?constituency2 . filter (?constituency != ?constituency2 ) . filter (str(?constituency) < str(?constituency2) ) filter (?term = ?term2 ) . filter (?election = ?election2 ) optional {?election wdt:P585 ?date } ?election wdt:P31 wd:Q15283424 . ?election2 wdt:P31 wd:Q15283424 . ?term wdt:P279 wd:Q16707842 . ?term wdt:P279 wd:Q16707842 . } ORDER BY DESC(?date) ?itemLabel

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#>
# MPs returned for more than one seat at the same election
SELECT DISTINCT ?item ?itemLabel ?electionLabel ?constituencyLabel ?constituency2Label  {
  ?item p:P39 ?positionStatement . ?positionStatement ps:P39 ?term . ?positionStatement pq:P768 ?constituency . ?positionStatement pq:P2715 ?election . 
  SERVICE wikibase:label { bd:serviceParam wikibase:language 'en' } 
  ?item p:P39 ?positionStatement2 . ?positionStatement2 ps:P39 ?term2 . ?positionStatement2 pq:P2715 ?election2 . ?positionStatement2 pq:P768 ?constituency2 . 
  filter (?constituency != ?constituency2 ) . filter (str(?constituency) < str(?constituency2) ) 
  filter (?term = ?term2 ) . filter (?election = ?election2 ) 
  optional {?election wdt:P585 ?date }
  ?election wdt:P31 wd:Q15283424 . ?election2 wdt:P31 wd:Q15283424 .
  ?term wdt:P279* wd:Q16707842 . ?term wdt:P279* wd:Q16707842 .
}
ORDER BY DESC(?date) ?itemLabel

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v7("?constituency") v8("?constituency2") v1("?date") v3("?election") v4("?election2") v9("?item"):::projected v2("?itemLabel"):::projected v10("?positionStatement") v11("?positionStatement2") v5("?term") v6("?term2") c13(["wd:Q16707842"]):::iri c8(["en"]):::literal c6(["bd:serviceParam"]):::iri c11(["wd:Q15283424"]):::iri f0[["?election = ?election2"]] f0 --> v3 f0 --> v4 f1[["?term = ?term2"]] f1 --> v5 f1 --> v6 f2[["str(?constituency) < str(?constituency2)"]] f2 --> v7 f2 --> v8 f3[["?constituency != ?constituency2"]] f3 --> v7 f3 --> v8 v9 --"p:P39"--> v10 v10 --"p:statement/P39"--> v5 v10 --"p:qualifier/P768"--> v7 v10 --"p:qualifier/P2715"--> v3 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c6 --"wikibase:language"--> c8 end v9 --"p:P39"--> v11 v11 --"p:statement/P39"--> v6 v11 --"p:qualifier/P2715"--> v4 v11 --"p:qualifier/P768"--> v8 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v3 -."p:direct/P585".-> v1 end v3 --"p:direct/P31"--> c11 v4 --"p:direct/P31"--> c11 v5 --"p:direct/P279"--> c13 v5 --"p:direct/P279"--> c13