query-38f39d6fe64ca8ef14ebdc5031d632bc
TODO
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT distinct ?item ?itemLabel ?urban_municipality_rankLabel ?start_date ?end_date WHERE {
VALUES ?type {wd:Q42744322 wd:Q22865 wd:Q134626 wd:Q448801 wd:Q1548518 wd:Q1548525 wd:Q54935786}
?item p:P31/p:P279* ?statement .
?statement ps:P31 ?type.
?statement wikibase:rank ?urban_municipality_rank .
optional {?statement pq:P580 ?start_date . }
optional {?statement pq:P582 ?end_date . }
filter not exists {?statement pq:P582 ?end_date . }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} order by ?itemLabel
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v3("?end_date"):::projected
v5("?item"):::projected
v1("?itemLabel"):::projected
v7("?start_date"):::projected
v2("?statement")
v4("?type")
v6("?urban_municipality_rank")
a1((" "))
c8(["bd:serviceParam"]):::iri
c10(["#91;AUTO_LANGUAGE#93;,en"]):::literal
f0[["not "]]
subgraph f0e0["Exists Clause"]
e0v1 --"p:qualifier/P582"--> e0v2
e0v2("?end_date"):::projected
e0v1("?statement"):::projected
end
f0--EXISTS--> f0e0
f0 --> v2
f0 --> c1
f0 --> v3
v2 --"p:qualifier/P582"--> v3
bind1[/VALUES ?type/]
bind1-->v4
bind10(["wd:Q42744322"])
bind10 --> bind1
bind11(["wd:Q22865"])
bind11 --> bind1
bind12(["wd:Q134626"])
bind12 --> bind1
bind13(["wd:Q448801"])
bind13 --> bind1
bind14(["wd:Q1548518"])
bind14 --> bind1
bind15(["wd:Q1548525"])
bind15 --> bind1
bind16(["wd:Q54935786"])
bind16 --> bind1
v5 --"p:P31"--> a1
a1 --"p:P279"--> v2
v2 --"p:statement/P31"--> v4
v2 --"wikibase:rank"--> v6
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v2 -."p:qualifier/P580".-> v7
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v2 -."p:qualifier/P582".-> v3
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c8 --"wikibase:language"--> c10
end