query-cb59da0209328a7e9711ba6056de189b

rq turtle/ttl

Help simplifying query: Request all officeholders (p:P1308) and applies to jurisdiction (p:P1001) of governors of a mexican state (wdt:Q17810142)Hello community, I have a working query that retrieves the values of 2 properties of a query. It works I just think there's a better way to write this. I'm looking for something along the lines of: From all items that are subclass wdt:P279 of state governor of mexico wd:Q17810142, give me the values for p:P1001 and p:P1308

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 p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item ?itemLabel ?state ?stateLabel
WHERE {
  # from all items that are subclass of state governor of mexico retrieve all items that have property p:P1308 and all items that have property p:1001
  ?wiki_items p:P1308 ?statement. 
  ?wiki_items wdt:P279 wd:Q17810142.
  ?statement ps:P1308 ?item.
  ?wiki_items p:P1001 ?other_statement.
  ?other_statement ps:P1001 ?state.
  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; v3("?item"):::projected v4("?other_statement") v5("?state"):::projected v2("?statement") v1("?wiki_items") c8(["bd:serviceParam"]):::iri c10(["#91;AUTO_LANGUAGE#93;,en"]):::literal c3(["wd:Q17810142"]):::iri v1 --"p:P1308"--> v2 v1 --"p:direct/P279"--> c3 v2 --"p:statement/P1308"--> v3 v1 --"p:P1001"--> v4 v4 --"p:statement/P1001"--> v5 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c8 --"wikibase:language"--> c10 end