query-5ba942c84e00007f538ddd0520d8f2c7
List of countries that share locations between a country (and at least one) non recognised count SELECT ?country ?countryLabel ?country2 ?country2Label (COUNT(DISTINCT ?object) AS ?count) WHERE { ?object wdt:P17 ?country. #Belonging to a county ?object wdt:P17 ?country2. 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 ?country2 wdt:P31/wdt:P279 wd:Q15634554. 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#>
#List of countries that share locations between a country (and at least one) non recognised count
SELECT ?country ?countryLabel ?country2 ?country2Label (COUNT(DISTINCT ?object) AS ?count)
WHERE {
?object wdt:P17 ?country. #Belonging to a county
?object wdt:P17 ?country2.
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
?country2 wdt:P31/wdt:P279* wd:Q15634554.
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)