query-f7d5711b9630e957e349284468e6b09a
ElectionsNumber of men and women returned at general elections
Use at
- https://query.wikidata.org/sparql
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 distinct ?election ?electionLabel ?members ?women ?men where
{
{ SELECT distinct ?election ?electiondate where
{ ?election wdt:P31 wd:Q15283424 . ?election wdt:P585 ?electiondate . }
} # find all general elections and their date (for sorting)
{ SELECT ?election (count(distinct ?item) as ?members) where
{ ?item p:P39 ?positionStatement . ?positionStatement ps:P39 ?membership .
?membership wdt:P2715 ?election . ?positionStatement pq:P2715 ?election .
} group by ?election
} # number of people elected in this election
# this code finds anyone who served the parliamentary term linked to this election
# with a P39 value which started with this election
{ SELECT ?election (count(distinct ?item) as ?women) where
{ ?item p:P39 ?positionStatement . ?positionStatement ps:P39 ?membership .
?membership wdt:P2715 ?election . ?positionStatement pq:P2715 ?election .
?item wdt:P21 wd:Q6581072 .
} group by ?election
} # as above, count only women
{ SELECT ?election (count(distinct ?item) as ?men) where
{ ?item p:P39 ?positionStatement . ?positionStatement ps:P39 ?membership .
?membership wdt:P2715 ?election . ?positionStatement pq:P2715 ?election .
?item wdt:P21 wd:Q6581097 .
} group by ?election
} # as above, count only men
SERVICE wikibase:label { bd:serviceParam wikibase:language 'en' }
} order by desc(?electiondate)
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v2("?election"):::projected
v1("?electiondate")
v3("?item")
v6("?members"):::projected
v5("?membership")
v8("?men"):::projected
v4("?positionStatement")
v7("?women"):::projected
c10(["wd:Q6581097"]):::iri
c14(["en"]):::literal
c9(["wd:Q6581072"]):::iri
c12(["bd:serviceParam"]):::iri
c2(["wd:Q15283424"]):::iri
v2 --"p:direct/P31"--> c2
v2 --"p:direct/P585"--> v1
v3 --"p:P39"--> v4
v4 --"p:statement/P39"--> v5
v5 --"p:direct/P2715"--> v2
v4 --"p:qualifier/P2715"--> v2
bind1[/"count(?item)"/]
v3 --o bind1
bind1 --as--o v6
v3 --"p:P39"--> v4
v4 --"p:statement/P39"--> v5
v5 --"p:direct/P2715"--> v2
v4 --"p:qualifier/P2715"--> v2
v3 --"p:direct/P21"--> c9
bind3[/"count(?item)"/]
v3 --o bind3
bind3 --as--o v7
v3 --"p:P39"--> v4
v4 --"p:statement/P39"--> v5
v5 --"p:direct/P2715"--> v2
v4 --"p:qualifier/P2715"--> v2
v3 --"p:direct/P21"--> c10
bind5[/"count(?item)"/]
v3 --o bind5
bind5 --as--o v8
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c12 --"wikibase:language"--> c14
end