query-8ef284603ade9017e0fd9cc5eb40c786
All different human settlements in a country that are also in another country SELECT ?object ?objectLabel ?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 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 different human settlements in a country that are also in another country
SELECT ?object ?objectLabel ?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
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)