query-4a34fa39089e71d0a6afadb9d34eafbb

rq turtle/ttl

Municipalities in Hesse

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX v: <http://www.wikidata.org/prop/statement/>
SELECT ?muni ?key ?muniLabel ?ruralLabel ?instanceLabel ?population WHERE {
  {
    VALUES ?instance {wd:Q42744322 wd:Q116457956} .
    ?muni wdt:P131 ?rural . ?rural wdt:P31 wd:Q61980413 .
    ?muni p:P31 ?instanceBlock . ?instanceBlock v:P31 ?instance .
  }
  UNION
  {
    VALUES ?instance {wd:Q61980648} .
    ?muni p:P31 ?instanceBlock . ?instanceBlock v:P31 ?instance
  }
  FILTER NOT EXISTS {?instanceBlock pq:P582 ?end}
  ?muni wdt:P1082 ?population .
  OPTIONAL{?muni wdt:P439 ?key}
  SERVICE wikibase:label{bd:serviceParam wikibase:language "de"}
}
ORDER BY ?key

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v3("?end") v7("?instance") v2("?instanceBlock") v1("?key"):::projected v5("?muni"):::projected v7("?population"):::projected v6("?rural") c12(["de"]):::literal c10(["bd:serviceParam"]):::iri c4(["wd:Q61980413"]):::iri f0[["not "]] subgraph f0e0["Exists Clause"] e0v1 --"p:qualifier/P582"--> e0v2 e0v2("?end"):::projected e0v1("?instanceBlock"):::projected end f0--EXISTS--> f0e0 f0 --> v2 f0 --> c1 f0 --> v3 v2 --"p:qualifier/P582"--> v3 subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; bind1[/VALUES ?instance/] bind1-->v7 bind10(["wd:Q61980648"]) bind10 --> bind1 v5 --"p:P31"--> v2 v2 --"p:statement/P31"--> v7 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; bind2[/VALUES ?instance/] bind2-->v7 bind20(["wd:Q42744322"]) bind20 --> bind2 bind21(["wd:Q116457956"]) bind21 --> bind2 v5 --"p:direct/P131"--> v6 v6 --"p:direct/P31"--> c4 v5 --"p:P31"--> v2 v2 --"p:statement/P31"--> v7 end union0r <== or ==> union0l end v5 --"p:direct/P1082"--> v7 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v5 -."p:direct/P439".-> v1 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c10 --"wikibase:language"--> c12 end