query-fdd9f1368c43c971ab320ecc3f6b236b

rq turtle/ttl

List of all current municipalities in SwitzerlandHi, I would like to create a list of all municipalities in Switzerland (excluding former municipalities). I currently have SELECT ?item ?itemLabel WHERE { ?item p:P31 ?inst . ?inst ps:P31 wd:Q70208 . # Swiss municipalities FILTER NOT EXISTS {?item wdt:P31 wd:Q685309} # remove former municipalities FILTER NOT EXISTS {?inst pq:P582 ?endtime} # remove municipalities with end time SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,de" } } . What I would like to do is obtain all Swiss municipalities that fullfill these criteria: (Q1020189)Bözberg which used to be a municipality, then wasnt and now is again. Basically both these filters would hit (as far as I understand) a case like (Q1020189)Bözberg this got me real close, but then I realized that this would also remove instances such as (they are still "former")(P582)end time which do not have (Q685309)former municipality of Switzerland (P31)instance of remove all items with (P582)end time and not qualifier (Q70208)municipality of Switzerland (P31)instance of have ]reply[21:25, 19 June 2020 (UTC)) talk (Hannes RöstThanks a lot --: Hannes Röst@

Use at

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#>
SELECT ?item ?itemLabel
WHERE
{
  # VALUES ?item { wd:Q1020189 }
  ?item wdt:P31 wd:Q70208 .
  MINUS {?item wdt:P31 wd:Q685309 }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en"  }  
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v1("?item"):::projected c3(["wd:Q685309"]):::iri c5(["bd:serviceParam"]):::iri c7(["#91;AUTO_LANGUAGE#93;,en"]):::literal c2(["wd:Q70208"]):::iri v1 --"wdt:P31"--> c2 subgraph minus0["MINUS"] style minus0 stroke-width:6px,fill:pink,stroke:red; v1 --"wdt:P31"--> c3 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c5 --"wikibase:language"--> c7 end