query-3cc8b283cd7a330ec8495d034ec32e4f

rq turtle/ttl

Battles in Europe with a place but no date SELECT DISTINCT ?item ?itemLabel (SAMPLE(?place_label) AS ?place_label) (SAMPLE(?coords) AS ?coords) WHERE { ?item wdt:P31/wdt:P279* wd:Q178561 . MINUS { ?item wdt:P31 wd:Q26913948 . }

# Place ?item (wdt:P17|wdt:P276|wdt:P706|wdt:P131)*/wdt:P30 wd:Q46 . ?item wdt:P276 ?place . OPTIONAL { ?place rdfs:label ?place_label . FILTER(LANG(?place_label) IN ("en", "fr")) . }

# Coords OPTIONAL { ?item wdt:P625 ?coordsItem . } OPTIONAL { ?place wdt:P625 ?coordsPlace . } BIND(COALESCE(?coordsItem, ?coordsPlace) AS ?coords)

FILTER NOT EXISTS { ?item (wdt:P585|wdt:P580|wdt:P582) ?date . }

SERVICE wikibase:label { bd:serviceParam wikibase:language "fr,en" } } GROUP BY ?item ?itemLabel ORDER BY ?coords

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>
# Battles in Europe with a place but no date
SELECT DISTINCT ?item ?itemLabel (SAMPLE(?place_label) AS ?place_label) (SAMPLE(?coords) AS ?coords) WHERE {
  ?item wdt:P31/wdt:P279* wd:Q178561 .
  MINUS { ?item wdt:P31 wd:Q26913948 . }

  # Place
  ?item (wdt:P17|wdt:P276|wdt:P706|wdt:P131)*/wdt:P30 wd:Q46 .
  ?item wdt:P276 ?place .
  OPTIONAL { ?place rdfs:label ?place_label . FILTER(LANG(?place_label) IN ("en", "fr")) . }

  # Coords
  OPTIONAL { ?item wdt:P625 ?coordsItem . }
  OPTIONAL { ?place wdt:P625 ?coordsPlace . }
  BIND(COALESCE(?coordsItem, ?coordsPlace) AS ?coords)

  FILTER NOT EXISTS { ?item (wdt:P585|wdt:P580|wdt:P582)  ?date . }

  SERVICE wikibase:label { bd:serviceParam wikibase:language "fr,en" }
} GROUP BY ?item ?itemLabel  ORDER BY ?coords

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v8("?coords"):::projected v6("?coordsItem") v7("?coordsPlace") v3("?date") v2("?item"):::projected v5("?place") v8("?place_label"):::projected a1((" ")) a2((" ")) c9(["wd:Q26913948"]):::iri c15(["wd:Q46"]):::iri c19(["bd:serviceParam"]):::iri c8(["wd:Q178561"]):::iri c21(["fr,en"]):::literal f0[["not "]] subgraph f0e0["Exists Clause"] subgraph unione00[" Union "] subgraph unione00l[" "] style unione00l fill:#abf,stroke-dasharray: 3 3; subgraph unione01[" Union "] subgraph unione01l[" "] style unione01l fill:#abf,stroke-dasharray: 3 3; e0v1 --"wdt:P582"--> e0v2 end subgraph unione01r[" "] style unione01r fill:#abf,stroke-dasharray: 3 3; e0v1 --"wdt:P580"--> e0v2 end unione01r <== or ==> unione01l end end subgraph unione00r[" "] style unione00r fill:#abf,stroke-dasharray: 3 3; e0v1 --"wdt:P585"--> e0v2 end unione00r <== or ==> unione00l end e0v2("?date"):::projected e0v1("?item"):::projected end f0--EXISTS--> f0e0 f0 --> v2 f0 --> c1 f0 --> v3 f0 --> c2 f0 --> c3 subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; subgraph union1[" Union "] subgraph union1l[" "] style union1l fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P582"--> v3 end subgraph union1r[" "] style union1r fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P580"--> v3 end union1r <== or ==> union1l end end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P585"--> v3 end union0r <== or ==> union0l end v2 --"wdt:P31"--> a1 a1 --"wdt:P279"--> c8 subgraph minus1["MINUS"] style minus1 stroke-width:6px,fill:pink,stroke:red; v2 --"wdt:P31"--> c9 end subgraph union2[" Union "] subgraph union2l[" "] style union2l fill:#abf,stroke-dasharray: 3 3; subgraph union3[" Union "] subgraph union3l[" "] style union3l fill:#abf,stroke-dasharray: 3 3; subgraph union4[" Union "] subgraph union4l[" "] style union4l fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P131"--> a2 end subgraph union4r[" "] style union4r fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P706"--> a2 end union4r <== or ==> union4l end end subgraph union3r[" "] style union3r fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P276"--> a2 end union3r <== or ==> union3l end end subgraph union2r[" "] style union2r fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P17"--> a2 end union2r <== or ==> union2l end a2 --"wdt:P30"--> c15 v2 --"wdt:P276"--> v5 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v5 -."rdfs:label".-> v8 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v2 -."wdt:P625".-> v6 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v5 -."wdt:P625".-> v7 end bind2[/"?coordsItem?coordsPlace"/] v6 --o bind2 v7 --o bind2 bind2 --as--o v8 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c19 --"wikibase:language"--> c21 end bind5[/"sample(?place_label)"/] v8 --o bind5 bind5 --as--o v8 bind6[/"sample(?coords)"/] v8 --o bind6 bind6 --as--o v8