query-6889fee064bf31ca54d641b3a422f895
MPs descended from William I SELECT distinct ?mp ?mpLabel ?born ?died WHERE { ?mp p:P39 ?positionStatement . ?positionStatement ps:P39 ?membership . # this person is a member of parliament { ?membership wdt:P279 wd:Q16707842 } # person was a UK MP UNION { ?membership wdt:P279 wd:Q18015642 } # or a British MP (to 1801) UNION { ?membership wdt:P279 wd:Q18018860 } # or an English MP (to 1707) OPTIONAL { ?mp wdt:P569 ?born } . OPTIONAL { ?mp wdt:P570 ?died } . { wd:Q37594 wdt:P40 ?mp . } # person's child, or their child's child, and so on union { ?mp (wdt:P25|wdt:P22)* wd:Q37594 . } # person's parent, or their parent's parent, and so on # # must replace Q37594 in both of the above lines to make this work properly # 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 p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
# MPs descended from William I
SELECT distinct ?mp ?mpLabel ?born ?died WHERE {
?mp p:P39 ?positionStatement .
?positionStatement ps:P39 ?membership . # this person is a member of parliament
{ ?membership wdt:P279* wd:Q16707842 } # person was a UK MP
UNION { ?membership wdt:P279* wd:Q18015642 } # or a British MP (to 1801)
UNION { ?membership wdt:P279* wd:Q18018860 } # or an English MP (to 1707)
OPTIONAL { ?mp wdt:P569 ?born } .
OPTIONAL { ?mp wdt:P570 ?died } .
{ wd:Q37594 wdt:P40* ?mp . } # person's child, or their child's child, and so on
union
{ ?mp (wdt:P25|wdt:P22)* wd:Q37594 . } # person's parent, or their parent's parent, and so on
#
# must replace Q37594 in both of the above lines to make this work properly
#
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } }