query-0c71fc5dcbdf7f270473e9858a4e898f
for the parish-or-burgh statements. But that (apparently simple?) change makes the following time out: p:P131/ps:P131 to a wdt:P131However, in a few cases the P131 for the council area has been given preferred ranks, so I would like to change the
Use at
- https://query.wikidata.org/sparql
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 ps: <http://www.wikidata.org/prop/statement/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?hs ?item ?itemLabel ?council_area ?council_areaLabel ?parish ?parishLabel (GROUP_CONCAT(?ca2_label; separator=' / ') AS ?ca2List) ?coords WHERE {
VALUES ?loc_type {wd:Q5124673 wd:Q6489113 wd:Q7543008} .
?item p:P131/ps:P131 ?parish .
?parish wdt:P31 ?loc_type .
?item wdt:P131 ?council_area .
?council_area wdt:P31 wd:Q15060255 .
MINUS {
VALUES ?loc_type1 {wd:Q5124673 wd:Q6489113 wd:Q7543008}
?item p:P131/ps:P131 ?parish1 .
?parish1 wdt:P31 ?loc_type1 .
?parish1 wdt:P131 ?council_area
} .
?parish wdt:P131 ?ca2 .
?ca2 wdt:P31 wd:Q15060255 .
?ca2 rdfs:label ?ca2_label FILTER(lang(?ca2_label) = 'en') .
optional {?item wdt:P625 ?coords} .
optional {?item wdt:P709 ?hs} .
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} GROUP BY ?item ?itemLabel ?council_area ?council_areaLabel ?parish ?parishLabel ?coords ?hs
ORDER BY ?itemLabel ?parishLabel ?ca2Label
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v11("?ca2")
v3("?ca2Label")
v14("?ca2List")
v4("?ca2_label"):::projected
v12("?coords"):::projected
v8("?council_area"):::projected
v13("?hs"):::projected
v6("?item"):::projected
v1("?itemLabel"):::projected
v5("?loc_type")
v9("?loc_type1")
v7("?parish"):::projected
v10("?parish1")
v2("?parishLabel"):::projected
a1((" "))
a2((" "))
c6(["wd:Q15060255"]):::iri
c11(["bd:serviceParam"]):::iri
c13(["#91;AUTO_LANGUAGE#93;,en"]):::literal
f0[["?ca2_label = 'en'"]]
f0 --> v4
bind1[/VALUES ?loc_type/]
bind1-->v5
bind10(["wd:Q5124673"])
bind10 --> bind1
bind11(["wd:Q6489113"])
bind11 --> bind1
bind12(["wd:Q7543008"])
bind12 --> bind1
v6 --"p:P131"--> a1
a1 --"p:statement/P131"--> v7
v7 --"p:direct/P31"--> v5
v6 --"p:direct/P131"--> v8
v8 --"p:direct/P31"--> c6
subgraph minus2["MINUS"]
style minus2 stroke-width:6px,fill:pink,stroke:red;
bind3[/VALUES ?loc_type1/]
bind3-->v9
bind30(["wd:Q5124673"])
bind30 --> bind3
bind31(["wd:Q6489113"])
bind31 --> bind3
bind32(["wd:Q7543008"])
bind32 --> bind3
v6 --"p:P131"--> a2
a2 --"p:statement/P131"--> v10
v10 --"p:direct/P31"--> v9
v10 --"p:direct/P131"--> v8
end
v7 --"p:direct/P131"--> v11
v11 --"p:direct/P31"--> c6
v11 --"rdfs:label"--> v4
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v6 -."p:direct/P625".-> v12
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v6 -."p:direct/P709".-> v13
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c11 --"wikibase:language"--> c13
end
bind5[/"?ca2_label"/]
v4 --o bind5
bind5 --as--o v14