query-e8e88f77fff78f43721c1bbab65f114c

rq turtle/ttl

List of all towns and cities in Germany 12:12, 8 December 2018 (UTC)) talk (Christoph Braun only appear once. Thanks in advance for any help or suggestions. Regards, (Q365)Cologne does not return the result I'm looking for. Several cities are returned multiple times because multiple subclasses apply to them. I'm looking for a way to either truncate these additional, but unwanted results or limit the output to the deepest subclass, so that cities like (Q42744322)urban municipality in Germany (P279)subclass of and (P31)instance of Hi, I'm looking for a query that shows all towns and cities in Germany (similar to the Catalonia example above). Querying through

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 {
  ?item wdt:P31/wdt:P279* wd:Q42744322;
        wdt:P625 ?geo .
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; v2("?geo") v1("?item"):::projected a1((" ")) c6(["bd:serviceParam"]):::iri c3(["wd:Q42744322"]):::iri c8(["#91;AUTO_LANGUAGE#93;,en"]):::literal v1 --"wdt:P31"--> a1 a1 --"wdt:P279"--> c3 v1 --"wdt:P625"--> v2 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c6 --"wikibase:language"--> c8 end