query-67dfdd4c56884385f849f680a4c611a1
Note: property paths are always "required" and never "optional" SELECT ?president ?relationshipEnd WHERE {
?president wdt:P31 wd:Q5 . # required wdt:P31 ?president p:P39 ?position_held_statement . # required p:P39 ?position_held_statement ps:P39 wd:Q11696 . # required ps:P39
?president p:P26/pq:P582 ?relationshipEnd # required p:P26 and pq:P582
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 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#>
#Note: property paths are always "required" and never "optional"
SELECT
?president
?relationshipEnd
WHERE {
?president wdt:P31 wd:Q5 . # required wdt:P31
?president p:P39 ?position_held_statement . # required p:P39
?position_held_statement ps:P39 wd:Q11696 . # required ps:P39
?president p:P26/pq:P582 ?relationshipEnd # required p:P26 and pq:P582
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("?position_held_statement")
v1("?president"):::projected
v3("?relationshipEnd"):::projected
a1((" "))
c9(["bd:serviceParam"]):::iri
c2(["wd:Q5"]):::iri
c11(["#91;AUTO_LANGUAGE#93;,en"]):::literal
c5(["wd:Q11696"]):::iri
v1 --"p:direct/P31"--> c2
v1 --"p:P39"--> v2
v2 --"p:statement/P39"--> c5
v1 --"p:P26"--> a1
a1 --"p:qualifier/P582"--> v3
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c9 --"wikibase:language"--> c11
end