query-14071478c225f9dbba15abf51a877a31

rq turtle/ttl

Forts in a real country, even if historical country mentioned

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT DISTINCT ?item ?itemLabel ?country1Label ?country2Label WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en-gb,en,mul". }
  {
    SELECT DISTINCT ?item ?country1 ?country2 WHERE {
      ?item p:P31 ?statement0.
      ?statement0 (ps:P31/(wdt:P279*)) wd:Q1785071.
      ?item wdt:P17 ?country1.
      ?item wdt:P17 ?country2.
      filter(str(?country1) != str(?country2))
      {{?country1 wdt:P31 wd:Q3024240}. MINUS{?country2 wdt:P31 wd:Q3024240}}
      {{?country2 wdt:P31 wd:Q3024240}. MINUS{?country1 wdt:P31 wd:Q3024240}}
    }
  }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v1("?country1") v2("?country2") v3("?item"):::projected v4("?statement0") a1((" ")) c4(["en-gb,en,mul"]):::literal c11(["wd:Q3024240"]):::iri c2(["bd:serviceParam"]):::iri c8(["wd:Q1785071"]):::iri subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c2 --"wikibase:language"--> c4 end f0[["str(?country1) != str(?country2)"]] f0 --> v1 f0 --> v2 v3 --"p:P31"--> v4 v4 --"p:statement/P31"--> a1 a1 --"p:direct/P279"--> c8 v3 --"p:direct/P17"--> v1 v3 --"p:direct/P17"--> v2 v1 --"p:direct/P31"--> c11 subgraph minus1["MINUS"] style minus1 stroke-width:6px,fill:pink,stroke:red; v2 --"p:direct/P31"--> c11 end v2 --"p:direct/P31"--> c11 subgraph minus2["MINUS"] style minus2 stroke-width:6px,fill:pink,stroke:red; v1 --"p:direct/P31"--> c11 end