query-ec2eefd9ae1f4f659519276270221a35
All human settlements that are are in a country (and at least one) non recognised country SELECT DISTINCT ?object ?objectLabel ?country ?countryLabel ?country2 ?country2Label #(COUNT(DISTINCT ?object) AS ?count) WHERE { ?object wdt:P17 ?country. #Belonging to a county ?object wdt:P17 ?country2. ?country2 wdt:P31/wdt:P279 wd:Q15634554. #Non recognised countries MINUS{?object wdt:P31/wdt:P279 wd:Q15239622.} #Filtering out all disputed territorry FILTER(STR(?country2) != STR(?country)) # use < instead of != to have each result only once MINUS { ?country wdt:P582|wdt:P576 ?ended. } #Countries have not ended or dissolved MINUS { ?country2 wdt:P582|wdt:P576 ?ended.} MINUS {?country wdt:P31/wdt:P279 wd:Q3024240} #Former countries MINUS {?country2 wdt:P31/wdt:P279 wd:Q3024240} ?object wdt:P31/wdt:P279* wd:Q486972. #Human settlements SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } }
GROUP BY ?country ?countryLabel ?country2 ?country2Label
ORDER BY DESC(?count)
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 human settlements that are are in a country (and at least one) non recognised country
SELECT DISTINCT ?object ?objectLabel ?country ?countryLabel ?country2 ?country2Label #(COUNT(DISTINCT ?object) AS ?count)
WHERE {
?object wdt:P17 ?country. #Belonging to a county
?object wdt:P17 ?country2.
?country2 wdt:P31/wdt:P279* wd:Q15634554. #Non recognised countries
MINUS{?object wdt:P31/wdt:P279* wd:Q15239622.} #Filtering out all disputed territorry
FILTER(STR(?country2) != STR(?country)) # use < instead of != to have each result only once
MINUS { ?country wdt:P582|wdt:P576 ?ended. } #Countries have not ended or dissolved
MINUS { ?country2 wdt:P582|wdt:P576 ?ended.}
MINUS {?country wdt:P31/wdt:P279* wd:Q3024240} #Former countries
MINUS {?country2 wdt:P31/wdt:P279* wd:Q3024240}
?object wdt:P31/wdt:P279* wd:Q486972. #Human settlements
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
#GROUP BY ?country ?countryLabel ?country2 ?country2Label
#ORDER BY DESC(?count)