query-fb1c40899bfb05eeeb5e914085d1dbb8
Comuni da aggiornare SELECT ?provincia ?provinciaLabel ?comune ?comuneLabel WHERE { # Comuni e comuni sparsi italiani { ?comune wdt:P31 wd:Q747074 . # Italian municipality } UNION { ?comune wdt:P31 wd:Q954172 . # Italian sparse municipality }
MINUS { # Comuni e comuni sparsi correttamente assegnati a province e similari
?regione p:P31/ps:P31/wdt:P279* wd:Q16110 . # Regions of Italia
?provincia wdt:P131 ?regione . # Administrative divisions in the region
{ ?provincia wdt:P31 wd:Q15089 . } # List of provinces
UNION
{ ?provincia wdt:P31 wd:Q15110 . } # metropolitan cities of Italy
UNION
{ ?provincia wdt:P31 wd:Q21190155 . } # Liberi consorzi comunali of Sicily
?comune wdt:P131 ?provincia . # Administrative divisions in the province
{
?comune wdt:P31 wd:Q747074 . # Italian municipality
}
UNION
{
?comune wdt:P31 wd:Q954172 . # Italian sparse municipality
}
}
?comune wdt:P131 ?provincia .
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } } order by ?comuneLabel
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 ps: <http://www.wikidata.org/prop/statement/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#Comuni da aggiornare
SELECT ?provincia ?provinciaLabel ?comune ?comuneLabel
WHERE
{
# Comuni e comuni sparsi italiani
{
?comune wdt:P31 wd:Q747074 . # Italian municipality
}
UNION
{
?comune wdt:P31 wd:Q954172 . # Italian sparse municipality
}
MINUS
{
# Comuni e comuni sparsi correttamente assegnati a province e similari
?regione p:P31/ps:P31/wdt:P279* wd:Q16110 . # Regions of Italia
?provincia wdt:P131 ?regione . # Administrative divisions in the region
{ ?provincia wdt:P31 wd:Q15089 . } # List of provinces
UNION
{ ?provincia wdt:P31 wd:Q15110 . } # metropolitan cities of Italy
UNION
{ ?provincia wdt:P31 wd:Q21190155 . } # Liberi consorzi comunali of Sicily
?comune wdt:P131 ?provincia . # Administrative divisions in the province
{
?comune wdt:P31 wd:Q747074 . # Italian municipality
}
UNION
{
?comune wdt:P31 wd:Q954172 . # Italian sparse municipality
}
}
?comune wdt:P131 ?provincia .
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
order by ?comuneLabel
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v2("?comune"):::projected
v1("?comuneLabel"):::projected
v4("?provincia"):::projected
v3("?regione")
a1((" "))
a2((" "))
c3(["wd:Q954172"]):::iri
c11(["wd:Q21190155"]):::iri
c13(["bd:serviceParam"]):::iri
c7(["wd:Q16110"]):::iri
c10(["wd:Q15110"]):::iri
c15(["#91;AUTO_LANGUAGE#93;,en"]):::literal
c9(["wd:Q15089"]):::iri
c2(["wd:Q747074"]):::iri
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
v2 --"p:direct/P31"--> c3
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v2 --"p:direct/P31"--> c2
end
union0r <== or ==> union0l
end
subgraph minus0["MINUS"]
style minus0 stroke-width:6px,fill:pink,stroke:red;
v3 --"p:P31"--> a1
a1 --"p:statement/P31"--> a2
a2 --"p:direct/P279"--> c7
v4 --"p:direct/P131"--> v3
subgraph union1[" Union "]
subgraph union1l[" "]
style union1l fill:#abf,stroke-dasharray: 3 3;
subgraph union2[" Union "]
subgraph union2l[" "]
style union2l fill:#abf,stroke-dasharray: 3 3;
v4 --"p:direct/P31"--> c11
end
subgraph union2r[" "]
style union2r fill:#abf,stroke-dasharray: 3 3;
v4 --"p:direct/P31"--> c10
end
union2r <== or ==> union2l
end
end
subgraph union1r[" "]
style union1r fill:#abf,stroke-dasharray: 3 3;
v4 --"p:direct/P31"--> c9
end
union1r <== or ==> union1l
end
v2 --"p:direct/P131"--> v4
subgraph union3[" Union "]
subgraph union3l[" "]
style union3l fill:#abf,stroke-dasharray: 3 3;
v2 --"p:direct/P31"--> c3
end
subgraph union3r[" "]
style union3r fill:#abf,stroke-dasharray: 3 3;
v2 --"p:direct/P31"--> c2
end
union3r <== or ==> union3l
end
end
v2 --"p:direct/P131"--> v4
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c13 --"wikibase:language"--> c15
end