query-11747d459766872f403e9d68105941ce
Ambassadors descended from William I SELECT distinct ?person ?personLabel ?born ?died WHERE { { ?position wdt:P31 wd:Q18115939 . } union { ?position wdt:P31 wd:Q56760832 } . # position is UK ambassador or high commissioner ?person p:P39 ?positionStatement . ?positionStatement ps:P39 ?position OPTIONAL { ?person wdt:P569 ?born } . OPTIONAL { ?person wdt:P570 ?died } . { wd:Q37594 wdt:P40 ?person . } # person's child, or their child's child, and so on union { ?person (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#>
# Ambassadors descended from William I
SELECT distinct ?person ?personLabel ?born ?died WHERE {
{ ?position wdt:P31 wd:Q18115939 . } union { ?position wdt:P31 wd:Q56760832 } . # position is UK ambassador or high commissioner
?person p:P39 ?positionStatement . ?positionStatement ps:P39 ?position
OPTIONAL { ?person wdt:P569 ?born } .
OPTIONAL { ?person wdt:P570 ?died } .
{ wd:Q37594 wdt:P40* ?person . } # person's child, or their child's child, and so on
union
{ ?person (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". } }
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v4("?born"):::projected
v5("?died"):::projected
v2("?person"):::projected
v1("?position")
v3("?positionStatement")
c2(["wd:Q18115939"]):::iri
c3(["wd:Q56760832"]):::iri
c15(["en"]):::literal
c13(["bd:serviceParam"]):::iri
c8(["wd:Q37594"]):::iri
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
v1 --"p:direct/P31"--> c3
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v1 --"p:direct/P31"--> c2
end
union0r <== or ==> union0l
end
v2 --"p:P39"--> v3
v3 --"p:statement/P39"--> v1
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v2 -."p:direct/P569".-> v4
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v2 -."p:direct/P570".-> v5
end
subgraph union1[" Union "]
subgraph union1l[" "]
style union1l fill:#abf,stroke-dasharray: 3 3;
subgraph union2[" Union "]
subgraph union2l[" "]
style union2l fill:#abf,stroke-dasharray: 3 3;
v2 --"p:direct/P22"--> c8
end
subgraph union2r[" "]
style union2r fill:#abf,stroke-dasharray: 3 3;
v2 --"p:direct/P25"--> c8
end
union2r <== or ==> union2l
end
end
subgraph union1r[" "]
style union1r fill:#abf,stroke-dasharray: 3 3;
c8 --"p:direct/P40"--> v2
end
union1r <== or ==> union1l
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c13 --"wikibase:language"--> c15
end