query-3ba2daf18c227efdd9cf5e79550443c2
All UK and pre-Union MPs - England to 1707, GB 1707-1801, and UK 1801-date
SELECT DISTINCT ?person ?personLabel (sample(?born) AS ?born_sample) (sample(?died) AS ?died_sample) (sample(?fl) AS ?fl_sample) WHERE { ?person wdt:P31 wd:Q5 . # this person is a real person (not fictional) ?person p:P39 ?ps . # this person has a position statement ?ps ... ?ps ps:P39 ?position . # and the statement is for a ?position which is... { ?position wdt:P279 wd:Q16707842 } # a UK MP or a subclass (specific period) UNION { ?position wdt:P279 wd:Q18015642 } # OR a GB MP or a subclass (specific period) UNION { ?position wdt:P279* wd:Q18018860 } # OR an English MP or a subclass (specific period) optional { ?person wdt:P569 ?b . BIND(YEAR(?b) AS ?born ) } # identify the year of birth optional { ?person wdt:P570 ?d . BIND(YEAR(?d) AS ?died ) } # identify the year of death optional { ?person (wdt:P1317|wdt:P2031|wdt:P2032) ?f . BIND(YEAR(?f) AS ?fl ) } # three different kinds of fl. date SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } # name } GROUP BY ?person ?personLabel # needed for grouping
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 p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#All UK and pre-Union MPs - England to 1707, GB 1707-1801, and UK 1801-date
SELECT DISTINCT ?person ?personLabel (sample(?born) AS ?born_sample) (sample(?died) AS ?died_sample) (sample(?fl) AS ?fl_sample)
WHERE {
?person wdt:P31 wd:Q5 . # this person is a real person (not fictional)
?person p:P39 ?ps . # this person has a position statement ?ps ...
?ps ps:P39 ?position . # and the statement is for a ?position which is...
{ ?position wdt:P279* wd:Q16707842 } # a UK MP or a subclass (specific period)
UNION { ?position wdt:P279* wd:Q18015642 } # OR a GB MP or a subclass (specific period)
UNION { ?position wdt:P279* wd:Q18018860 } # OR an English MP or a subclass (specific period)
optional { ?person wdt:P569 ?b . BIND(YEAR(?b) AS ?born ) } # identify the year of birth
optional { ?person wdt:P570 ?d . BIND(YEAR(?d) AS ?died ) } # identify the year of death
optional { ?person (wdt:P1317|wdt:P2031|wdt:P2032) ?f . BIND(YEAR(?f) AS ?fl ) } # three different kinds of fl. date
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } # name
} GROUP BY ?person ?personLabel # needed for grouping