query-031a35d44a00c0f0a40627ad1ca41a3c
All former municipalities of Switzerland
MINUS those who also have a "current statement"
should be empty (all Q685309 should also be Q70208)
SELECT *
WITH
{
# select all that have both current AND former
SELECT ?item WHERE {
hint:Query hint:optimizer "None" .
?item wdt:P31 wd:Q685309 .
?item wdt:P31 wd:Q70208
}
} as %muni
WHERE
{
?item wdt:P31 wd:Q685309 .
MINUS { include %muni } # subtract those with qualifier from all Q685309
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,de" }
}
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#>
# All former municipalities of Switzerland
# MINUS those who also have a "current statement"
# should be empty (all Q685309 should also be Q70208)
SELECT *
WHERE
{
?item wdt:P31 wd:Q685309 .
MINUS {
{
# select all that have both current AND former
SELECT ?item WHERE {
?item wdt:P31 wd:Q685309 .
?item wdt:P31 wd:Q70208
}
}} # subtract those with qualifier from all Q685309
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,de" }
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v1("?item"):::projected
c2(["wd:Q685309"]):::iri
c5(["bd:serviceParam"]):::iri
c3(["wd:Q70208"]):::iri
c7(["#91;AUTO_LANGUAGE#93;,en,de"]):::literal
v1 --"wdt:P31"--> c2
subgraph minus0["MINUS"]
style minus0 stroke-width:6px,fill:pink,stroke:red;
v1 --"wdt:P31"--> c2
v1 --"wdt:P31"--> c3
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c5 --"wikibase:language"--> c7
end