query-c7fd497e0dc1a9ed0f922c5cb9ebc209

rq turtle/ttl

All national-level heads of government that are of a national-level head of government. s(P39)position held I'm trying to puzzle out how to find all So far I have:

Use at

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#>
SELECT DISTINCT ?person ?personLabel ?jurisdiction ?jurisdictionLabel ?position ?positionLabel ?start_date
WHERE {    
    ?person wdt:P31 wd:Q5 .                   # find all humans
    ?person p:P39 ?position_statement .       # who have held a position
    ?position_statement ps:P39 ?position .
    ?position wdt:P279* wd:Q2285706 .         # that is a subclass of head of government
    ?position wdt:P1001 ?jurisdiction .       # with a jurisdiction
    ?jurisdiction wdt:P31 wd:Q6256 .          # that is a country
    ?position_statement pq:P580 ?start_date . # and where the position statement has a start date
    SERVICE wikibase:label { bd:serviceParam wikibase:language "en" . }
  }
  ORDER BY ?jurisdictionLabel ?positionLabel

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v6("?jurisdiction"):::projected v1("?jurisdictionLabel"):::projected v3("?person"):::projected v5("?position"):::projected v2("?positionLabel"):::projected v4("?position_statement") v7("?start_date"):::projected c13(["en"]):::literal c11(["bd:serviceParam"]):::iri c2(["wd:Q5"]):::iri c6(["wd:Q2285706"]):::iri c8(["wd:Q6256"]):::iri v3 --"p:direct/P31"--> c2 v3 --"p:P39"--> v4 v4 --"p:statement/P39"--> v5 v5 --"p:direct/P279"--> c6 v5 --"p:direct/P1001"--> v6 v6 --"p:direct/P31"--> c8 v4 --"p:qualifier/P580"--> v7 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c11 --"wikibase:language"--> c13 end