query-0890849d8e164f354773593129e11fb8
All former MPs alive on election day (Andrew Gray)
note that election is explicitly hardcoded in three places because MINUS clauses are odd
SELECT distinct ?item ?itemLabel ?died ?born { ?item p:P39 ?positionStatement . ?positionStatement ps:P39 ?membership . ?membership wdt:P279 wd:Q16707842 . ?positionStatement pq:P582 ?end . FILTER (?end < ?electionday) . wd:Q3586935 wdt:P585 ?electionday . # find all MPs who served any terms in office before this date (nb will include any unknown end dates) MINUS { ?item wdt:P570 ?died . FILTER (?died < ?electionday) . wd:Q3586935 wdt:P585 ?electionday } MINUS { ?item wdt:P570 ?died . FILTER isBLANK(?died) . } # remove all who died before this date, or have a date of death unknown MINUS { ?item p:P39 ?positionStatement2 . ?positionStatement2 ps:P39 ?membership2 . ?membership2 wdt:P279 wd:Q16707842 . ?positionStatement2 pq:P2715 wd:Q3586935 . } # remove all those who were elected at this specific election and thus were an MP on that day optional { ?item wdt:P569 ?born } . SERVICE wikibase:label { bd:serviceParam wikibase:language 'en' } }
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#>
# All former MPs alive on election day (Andrew Gray)
# note that election is explicitly hardcoded in three places because MINUS clauses are odd
SELECT distinct ?item ?itemLabel ?died ?born
{
?item p:P39 ?positionStatement . ?positionStatement ps:P39 ?membership . ?membership wdt:P279 wd:Q16707842 .
?positionStatement pq:P582 ?end . FILTER (?end < ?electionday) . wd:Q3586935 wdt:P585 ?electionday .
# find all MPs who served any terms in office before this date (nb will include any unknown end dates)
MINUS { ?item wdt:P570 ?died . FILTER (?died < ?electionday) . wd:Q3586935 wdt:P585 ?electionday }
MINUS { ?item wdt:P570 ?died . FILTER isBLANK(?died) . }
# remove all who died before this date, or have a date of death unknown
MINUS { ?item p:P39 ?positionStatement2 . ?positionStatement2 ps:P39 ?membership2 .
?membership2 wdt:P279 wd:Q16707842 . ?positionStatement2 pq:P2715 wd:Q3586935 . }
# remove all those who were elected at this specific election and thus were an MP on that day
optional { ?item wdt:P569 ?born } .
SERVICE wikibase:label { bd:serviceParam wikibase:language 'en' }
}