query-c037400a5592b505202230a4abdedf0c

rq turtle/ttl

All events in the city between dates TODO

Use at

PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
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 pqv: <http://www.wikidata.org/prop/qualifier/value/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT distinct ?event ?eventLabel ?time ?begin ?end ?create ?destroy WHERE {
  VALUES ?city { wd:Q649 }.
  VALUES ?startTime {"1990-12-31"^^xsd:dat}.
  {?event wdt:P131* ?city.} UNION {?event wdt:P276 ?city.}
#  ?event wdt:P31/wdt:P279* wd:Q1190554. (anyway timesout)
  {?event p:P276 ?statement.
    ?statement pqv:P580 ?beginvalue;
               pqv:P582 ?endvalue;
               ps:P276 ?city.
    ?beginvalue wikibase:timeValue ?begin .
    ?endvalue wikibase:timeValue ?end .
    FILTER("1990-12-31"^^xsd:date < ?begin && ?begin < "2020-00-00"^^xsd:dat||
           "1990-12-31"^^xsd:date < ?end && ?end < "2020-00-00"^^xsd:dat)
 }
 UNION
  { ?event wdt:P585 ?time.
   FILTER("1990-12-31"^^xsd:date < ?time && ?time < "2020-00-00"^^xsd:dat)
  }
 UNION
  { ?event wdt:P580 ?begin;
           wdt:P582 ?end.
    FILTER("1990-12-31"^^xsd:date < ?begin && ?begin < "2020-00-00"^^xsd:date ||
           "1990-12-31"^^xsd:date < ?end && ?end < "2020-00-00"^^xsd:dat)
  }
 UNION
  { ?event wdt:P571 ?create;
           wdt:P576 ?destroy;
    FILTER("1990-12-31"^^xsd:date < ?create && ?create < "2020-00-00"^^xsd:date ||
           "1990-12-31"^^xsd:date < ?destroy && ?destroy < "2020-00-00"^^xsd:dat)
  }         
  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; v4("?begin"):::projected v7("?beginvalue") v1("?city") v10("?create"):::projected v11("?destroy"):::projected v5("?end"):::projected v8("?endvalue") v3("?event"):::projected v2("?startTime") v6("?statement") v9("?time"):::projected c17(["bd:serviceParam"]):::iri c19(["#91;AUTO_LANGUAGE#93;,en"]):::literal bind0[/VALUES ?city/] bind0-->v1 bind00(["wd:Q649"]) bind00 --> bind0 bind1[/VALUES ?startTime/] bind1-->v2 bind10([s1990-12-31^^<http://www.w3.org/2001/XMLSchema#dat>"]) bind10 --> bind1 subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; v3 --"p:direct/P276"--> v1 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v3 --"p:direct/P131"--> v1 end union0r <== or ==> union0l end subgraph union1[" Union "] subgraph union1l[" "] style union1l fill:#abf,stroke-dasharray: 3 3; 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; f2[["('1990-12-31^^xsd:date' < ?create?create < '2020-00-00^^xsd:date' || '1990-12-31^^xsd:date' < ?destroy?destroy < s2020-00-00^^<http://www.w3.org/2001/XMLSchema#dat>')"]] f2 --> v10 f2 --> v11 v3 --"p:direct/P571"--> v10 v3 --"p:direct/P576"--> v11 end subgraph union3r[" "] style union3r fill:#abf,stroke-dasharray: 3 3; f3[["('1990-12-31^^xsd:date' < ?begin?begin < '2020-00-00^^xsd:date' || '1990-12-31^^xsd:date' < ?end?end < s2020-00-00^^<http://www.w3.org/2001/XMLSchema#dat>')"]] f3 --> v4 f3 --> v5 v3 --"p:direct/P580"--> v4 v3 --"p:direct/P582"--> v5 end union3r <== or ==> union3l end end subgraph union2r[" "] style union2r fill:#abf,stroke-dasharray: 3 3; f4[["'1990-12-31^^xsd:date' < ?time?time < s2020-00-00^^<http://www.w3.org/2001/XMLSchema#dat>'"]] f4 --> v9 v3 --"p:direct/P585"--> v9 end union2r <== or ==> union2l end end subgraph union1r[" "] style union1r fill:#abf,stroke-dasharray: 3 3; f5[["('1990-12-31^^xsd:date' < ?begin?begin < s2020-00-00^^<http://www.w3.org/2001/XMLSchema#dat>' || '1990-12-31^^xsd:date' < ?end?end < s2020-00-00^^<http://www.w3.org/2001/XMLSchema#dat>')"]] f5 --> v4 f5 --> v5 v3 --"p:P276"--> v6 v6 --"p:qualifier/value/P580"--> v7 v6 --"p:qualifier/value/P582"--> v8 v6 --"p:statement/P276"--> v1 v7 --"wikibase:timeValue"--> v4 v8 --"wikibase:timeValue"--> v5 end union1r <== or ==> union1l end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c17 --"wikibase:language"--> c19 end