query-43a15e02a54d3d1a608158fbd93f0cce

rq turtle/ttl

Show all capitals of a country on a map SELECT * WHERE { ?item wdt:P31* wd:Q5119; wdt:P625 ?geo . } The problem is, that I also get the capital of Wales. But I only want the capital of Great Britain. And then I want to show them on a map. 13:35, 4 December 2018 (UTC)) talk (Steffenschneider123--Hi

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#>
#defaultView:Map
SELECT ?item ?geo ?itemLabel ?Capitale ?CapitaleLabel WHERE {
  ?item wdt:P31* wd:Q6256.
  ?item wdt:P625 ?geo.
  OPTIONAL { ?item wdt:P36 ?Capitale. }
  OPTIONAL { ?Capitale wdt:P625 ?geo.}
  MINUS    { ?item wdt:P576 [].}                    # remove items with P576 (dissolved, abolished or demolished) as a main property
  MINUS    { ?item wdt:P582 [].}                    # remove items with P582 (end date) as a main property
  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; v3("?Capitale"):::projected v2("?geo"):::projected v1("?item"):::projected a1((" ")) a2((" ")) c8(["bd:serviceParam"]):::iri c10(["#91;AUTO_LANGUAGE#93;,en"]):::literal c2(["wd:Q6256"]):::iri v1 --"wdt:P31"--> c2 v1 --"wdt:P625"--> v2 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P36".-> v3 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v3 -."wdt:P625".-> v2 end subgraph minus0["MINUS"] style minus0 stroke-width:6px,fill:pink,stroke:red; v1 --"wdt:P576"--> a1 end subgraph minus1["MINUS"] style minus1 stroke-width:6px,fill:pink,stroke:red; v1 --"wdt:P582"--> a2 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c8 --"wikibase:language"--> c10 end