query-943330e5a1b000e42cc92b9394303272

rq turtle/ttl

Number of German municipalities

Use at

PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX v: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>

SELECT (COUNT(?muni) AS ?numberOfGermanMunicipalities) WHERE{
SELECT DISTINCT ?muni WHERE {
  ?muni p:P31 ?instanceBlock . 
  ?instanceBlock v:P31 ?instance .
  {?instance wdt:P279+ wd:Q262166} UNION {BIND (wd:Q262166 AS ?instance)}
  FILTER NOT EXISTS {?instanceBlock pq:P582 ?end}
  ?muni wdt:P439 ?key
}
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v2("?end") v5("?instance") v1("?instanceBlock") v5("?key") v3("?muni"):::projected v6("?numberOfGermanMunicipalities") c5(["wd:Q262166"]):::iri f0[["not "]] subgraph f0e0["Exists Clause"] e0v1 --"p:qualifier/P582"--> e0v2 e0v2("?end"):::projected e0v1("?instanceBlock"):::projected end f0--EXISTS--> f0e0 f0 --> v1 f0 --> c1 f0 --> v2 v1 --"p:qualifier/P582"--> v2 v3 --"p:P31"--> v1 v1 --"p:statement/P31"--> v5 subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; bind1[/"'wd:Q262166'"/] bind1 --as--o v5 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v5 --"p:direct/P279"--> c5 end union0r <== or ==> union0l end v3 --"p:direct/P439"--> v5 bind3[/"count(?muni)"/] v3 --o bind3 bind3 --as--o v6