query-317771cc2303162c455cb467475c93f2

rq turtle/ttl

Battles between 476 and 1492 with a date but no place SELECT DISTINCT ?item ?itemLabel ?placeLabel ?date ?coords WHERE { ?item wdt:P31/wdt:P279* wd:Q178561 . # A battle or a subclass of it MINUS { ?item wdt:P31 wd:Q26913948 . } # but not a legendary one

# OPTIONAL { ?item (wdt:P585|wdt:P580|wdt:P582) ?date . } OPTIONAL { ?item wdt:P585 ?basicDate . } OPTIONAL { ?item wdt:P580 ?startDate . } OPTIONAL { ?item wdt:P582 ?endDate . } BIND(COALESCE(?basicDate, ?startDate, ?endDate) AS ?date) FILTER(BOUND(?date))

FILTER (YEAR(?date) >= 476) . FILTER (YEAR(?date) <= 1492) .

FILTER NOT EXISTS { ?item wdt:P276 ?place . }

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

SERVICE wikibase:label { bd:serviceParam wikibase:language "fr,en" } } ORDER BY ?date

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#>
# Battles between 476 and 1492 with a date but no place
SELECT DISTINCT ?item ?itemLabel  ?placeLabel ?date ?coords WHERE {
  ?item wdt:P31/wdt:P279* wd:Q178561 . # A battle or a subclass of it
  MINUS { ?item wdt:P31 wd:Q26913948 . } # but not a legendary one

  # OPTIONAL { ?item (wdt:P585|wdt:P580|wdt:P582)  ?date . }
  OPTIONAL { ?item wdt:P585 ?basicDate . }
  OPTIONAL { ?item wdt:P580 ?startDate . }
  OPTIONAL { ?item wdt:P582 ?endDate . }
  BIND(COALESCE(?basicDate, ?startDate, ?endDate) AS ?date)
  FILTER(BOUND(?date))

  FILTER (YEAR(?date) >= 476) . FILTER (YEAR(?date) <= 1492) .

  FILTER NOT EXISTS { ?item wdt:P276 ?place . }

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

  SERVICE wikibase:label { bd:serviceParam wikibase:language "fr,en" }
} ORDER BY ?date

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v4("?basicDate") v7("?coords"):::projected v7("?date"):::projected v6("?endDate") v2("?item"):::projected v3("?place") v5("?startDate") a1((" ")) c7(["wd:Q26913948"]):::iri c13(["bd:serviceParam"]):::iri c6(["wd:Q178561"]):::iri c15(["fr,en"]):::literal f0[["not "]] subgraph f0e0["Exists Clause"] e0v1 --"wdt:P276"--> e0v2 e0v1("?item"):::projected e0v2("?place"):::projected end f0--EXISTS--> f0e0 f0 --> v2 f0 --> c1 f0 --> v3 v2 --"wdt:P276"--> v3 f1[["year-from-dateTime(?date) <= '1492^^xsd:integer'"]] f1 --> v7 f2[["year-from-dateTime(?date) >= '476^^xsd:integer'"]] f2 --> v7 f3[["bound(?date)"]] f3 --> v7 v2 --"wdt:P31"--> a1 a1 --"wdt:P279"--> c6 subgraph minus4["MINUS"] style minus4 stroke-width:6px,fill:pink,stroke:red; v2 --"wdt:P31"--> c7 end subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v2 -."wdt:P585".-> v4 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v2 -."wdt:P580".-> v5 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v2 -."wdt:P582".-> v6 end bind5[/"?basicDate?startDate?endDate"/] v4 --o bind5 v5 --o bind5 v6 --o bind5 bind5 --as--o v7 subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v2 -."wdt:P625".-> v7 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c13 --"wikibase:language"--> c15 end