query-8c9eace2ed929428b3f37b4cb5695e33
Add missing municipality SELECT DISTINCT ?item ?itemLabel ?instanceLabel ?placeLabel ?city ?cityLabel WHERE { SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],nl,fr,de,en,es,it,no,se,fi". } ?item wdt:P17 wd:Q31; wdt:P31 ?instance; wdt:P276 ?place. ?place wdt:P131 ?city. { ?place wdt:P31 wd:Q532. } UNION { ?place wdt:P31 wd:Q2785216. } MINUS { ?item wdt:P131 _:b1. } }
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 bd: <http://www.bigdata.com/rdf#>
# Add missing municipality
SELECT DISTINCT ?item ?itemLabel ?instanceLabel ?placeLabel ?city ?cityLabel WHERE {
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],nl,fr,de,en,es,it,no,se,fi". }
?item wdt:P17 wd:Q31;
wdt:P31 ?instance;
wdt:P276 ?place.
?place wdt:P131 ?city.
{ ?place wdt:P31 wd:Q532. }
UNION
{ ?place wdt:P31 wd:Q2785216. }
MINUS { ?item wdt:P131 _:b1. }
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v4("?city"):::projected
v2("?instance")
v1("?item"):::projected
v3("?place")
a1((" "))
c10(["wd:Q532"]):::iri
c2(["bd:serviceParam"]):::iri
c4(["#91;AUTO_LANGUAGE#93;,nl,fr,de,en,es,it,no,se,fi"]):::literal
c6(["wd:Q31"]):::iri
c11(["wd:Q2785216"]):::iri
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c2 --"wikibase:language"--> c4
end
v1 --"wdt:P17"--> c6
v1 --"wdt:P31"--> v2
v1 --"wdt:P276"--> v3
v3 --"wdt:P131"--> v4
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
v3 --"wdt:P31"--> c11
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v3 --"wdt:P31"--> c10
end
union0r <== or ==> union0l
end
subgraph minus0["MINUS"]
style minus0 stroke-width:6px,fill:pink,stroke:red;
v1 --"wdt:P131"--> a1
end