query-d5fb78fec1e5c447c6b72ba40245a0c2
Weather station with no closure date OR closure after 1953. stations with no closure date, and another one for that were close afterwardsI am able to write a query to get the weather stations open in 1953 and should be in the result of the query below). I tried to revert the clauses between the "||" but it didn't change anything. (Q61039179)Kincardine Somehow, I am not able to combine the two conditions in one SPARQL query. The result of what I've been able to achieve only shows station with a closure date after 1953 but not those with no closure date (if the quere were successful,
Use at
- https://query.wikidata.org/sparql
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 bd: <http://www.bigdata.com/rdf#>
# Stations d'Ontario actives en 1953
#defaultView:Map
SELECT ?item ?itemLabel ?coord
WHERE {
?item (wdt:P31/wdt:P279*) wd:Q190107.
?item wdt:P131 wd:Q1904 .
?item wdt:P729 ?service_entry .
# service entry is before 1953
FILTER (?service_entry <= "1953-01-01T00:00:00Z"^^xsd:dateTime) .
# and closure date not before 1953
?item wdt:P3999 ?closureDate .
FILTER(
# Closure date is not set
?closureDate > "1953-01-01T00:00:00Z"^^xsd:dateTime|| NOT EXISTS { ?item wdt:P3999 [] } # or closure date is after 1953
)
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
OPTIONAL { ?item wdt:P625 ?coord. }
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v1("?closureDate")
v4("?coord"):::projected
v2("?item"):::projected
v3("?service_entry")
a1((" "))
a2((" "))
c7(["wd:Q1904"]):::iri
c5(["wd:Q190107"]):::iri
c10(["bd:serviceParam"]):::iri
c12(["#91;AUTO_LANGUAGE#93;,en"]):::literal
f0[["(?closureDate > '1953-01-01T00:00:00Z^^xsd:dateTime' || not )"]]
subgraph f0e0["Exists Clause"]
e0v1 --"wdt:P3999"--> e0a1
e0v1("?item"):::projected
e0a1((" ")):::projected
end
f0--EXISTS--> f0e0
f0 --> v1
f0 --> v2
f0 --> c2
f0 --> a1
v2 --"wdt:P3999"--> a1
f1[["?service_entry <= '1953-01-01T00:00:00Z^^xsd:dateTime'"]]
f1 --> v3
v2 --"wdt:P31"--> a2
a2 --"wdt:P279"--> c5
v2 --"wdt:P131"--> c7
v2 --"wdt:P729"--> v3
v2 --"wdt:P3999"--> v1
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c10 --"wikibase:language"--> c12
end
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v2 -."wdt:P625".-> v4
end