query-4ab4bb30985b10b12277f18f211b4f7c
Die 16 Bundesländer mit Anzahl ihrer Gemeinden
Use at
- https://query.wikidata.org/sparql
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 ?newOld (?prefix AS ?key) ?stateLabel (COUNT(?key) AS ?count) WHERE{
SELECT DISTINCT ?stateLabel ?muni ?prefix ?key ?newOld 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 .
BIND (SUBSTR(?key,1,2) AS ?prefix) .
?state wdt:P1388 ?prefix .
?state wdt:P571 ?inception BIND(if(YEAR(?inception)<1990,"old","new") as ?newOld)
SERVICE wikibase:label{bd:serviceParam wikibase:language "de"}
}
}
GROUP BY ?prefix ?stateLabel ?newOld
ORDER BY DESC(?newOld) ?stateLabel
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v11("?count")
v4("?end")
v10("?inception")
v7("?instance")
v3("?instanceBlock")
v11("?key"):::projected
v5("?muni")
v11("?newOld"):::projected
v8("?prefix"):::projected
v9("?state")
v2("?stateLabel"):::projected
c12(["de"]):::literal
c10(["bd:serviceParam"]):::iri
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 --> v3
f0 --> c1
f0 --> v4
v3 --"p:qualifier/P582"--> v4
v5 --"p:P31"--> v3
v3 --"p:statement/P31"--> v7
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
bind1[/"'wd:Q262166'"/]
bind1 --as--o v7
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v7 --"p:direct/P279"--> c5
end
union0r <== or ==> union0l
end
v5 --"p:direct/P439"--> v11
bind2[/"substring(?key,'1^^xsd:integer','2^^xsd:integer')"/]
v11 --o bind2
bind2 --as--o v8
v9 --"p:direct/P1388"--> v8
v9 --"p:direct/P571"--> v10
bind3[/"if(year-from-dateTime(?inception) < '1990^^xsd:integer','old','new')"/]
v10 --o bind3
bind3 --as--o v11
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c10 --"wikibase:language"--> c12
end
bind5[/"?prefix"/]
v8 --o bind5
bind5 --as--o v11
bind6[/"count(?key)"/]
v11 --o bind6
bind6 --as--o v11