query-e606c4f34fce1fc61fd14d959d3af63f

rq turtle/ttl

Head of state, current and past, of all states for every state the currently exists (though if the query returns data for historical states that's not a problem). The data should include every US president, every Swedish king/queen since Sweden was founded etc. I would like to retrieve the following values: (Q48352)head of state I'm looking for data on all The end time of the position. The start time of the position. The state in question. Label of the position ("US president", "Monarch of Australia" etc) Label of the person. Q-id for the person.Here's what I've got so far. I can't figure out how to get the state in it's own column.

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 ?hos ?hosLabel ?roleStatementLabel ?startYear ?endYear
WHERE {
  ?hos wdt:P31 wd:Q5 .
  ?hos p:P39 ?roleNode .
  ?roleNode ps:P39 ?roleStatement .
  ?roleStatement wdt:P31*/wdt:P279* wd:Q48352 .
  ?roleNode pq:P580 ?startYear .
  ?roleNode pq:P582 ?endYear .

  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }

Query found at