query-275d967abb2409575e94bf7f09dcdee3
Find patrilineal ancestors of US presidents SELECT DISTINCT ?president ?presidentLabel ?ancestor ?ancestorLabel WHERE { ?president wdt:P31 wd:Q5. # ?president is humam ?president wdt:P39 wd:Q11696. # ?president has position president of US ?president wdt:P22+ ?ancestor. SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_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 bd: <http://www.bigdata.com/rdf#>
# Find patrilineal ancestors of US presidents
SELECT DISTINCT ?president ?presidentLabel ?ancestor ?ancestorLabel
WHERE
{
?president wdt:P31 wd:Q5. # ?president is humam
?president wdt:P39 wd:Q11696. # ?president has position president of US
?president wdt:P22+ ?ancestor.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v2("?ancestor"):::projected
v1("?president"):::projected
c7(["bd:serviceParam"]):::iri
c2(["wd:Q5"]):::iri
c9(["#91;AUTO_LANGUAGE#93;,en"]):::literal
c4(["wd:Q11696"]):::iri
v1 --"wdt:P31"--> c2
v1 --"wdt:P39"--> c4
v1 --"wdt:P22"--> v2
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c7 --"wikibase:language"--> c9
end