query-0bc5fe107e8fac7c59d85d8b1007c1ad

rq turtle/ttl

Does this help?

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 ?constituency ?constituencyLabel ?expectedNumberOfSeats (COUNT (?startMP) as ?actualNumberOfEntries) 
{
 # find the MP elected at the general election which began the term
 wd:Q41582584 wdt:P2715 ?election .
 ?startMP p:P39 ?positionStatement2 .
 ?positionStatement2 ps:P39 wd:Q41582584 . 
 ?positionStatement2 pq:P768 ?constituency .
 ?positionStatement2 pq:P2715 ?election . 
 SERVICE wikibase:label { bd:serviceParam wikibase:language 'en' }
 OPTIONAL {
   ?constituency wdt:P1410 ?expectedNumberOfSeats .
 }
}
GROUP BY ?constituency ?constituencyLabel ?expectedNumberOfSeats
HAVING (?actualNumberOfEntries > 1)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v7("?actualNumberOfEntries") v5("?constituency"):::projected v2("?election") v6("?expectedNumberOfSeats"):::projected v4("?positionStatement2") v3("?startMP"):::projected c2(["wd:Q41582584"]):::iri c9(["bd:serviceParam"]):::iri c11(["en"]):::literal f0[["?actualNumberOfEntries > '1^^xsd:integer'"]] f0 --> v7 c2 --"p:direct/P2715"--> v2 v3 --"p:P39"--> v4 v4 --"p:statement/P39"--> c2 v4 --"p:qualifier/P768"--> v5 v4 --"p:qualifier/P2715"--> v2 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c9 --"wikibase:language"--> c11 end subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v5 -."p:direct/P1410".-> v6 end bind2[/"count(?startMP)"/] v3 --o bind2 bind2 --as--o v7