query-0d421f082677198456f9ee8e06203e9a

rq turtle/ttl

Time outThe following query runs in about 20 seconds: , and returns any with a council area that cannot be 'explained' by any of the parishes or burghs: (Q7543008)small burgh or (Q6489113)large burgh or (Q5124673)Scottish civil parish , and also to a (Q15060255)Scottish council area It looks for all Scottish items that have a P131 to a

Use at

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 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 wdt: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 wdt: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 c9(["bd:serviceParam"]):::iri c11(["#91;AUTO_LANGUAGE#93;,en"]):::literal c4(["wd:Q15060255"]):::iri 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 --"wdt:P131"--> v7 v7 --"wdt:P31"--> v5 v6 --"wdt:P131"--> v8 v8 --"wdt:P31"--> c4 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 --"wdt:P131"--> v10 v10 --"wdt:P31"--> v9 v10 --"wdt:P131"--> v8 end v7 --"wdt:P131"--> v11 v11 --"wdt:P31"--> c4 v11 --"rdfs:label"--> v4 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v6 -."wdt:P625".-> v12 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v6 -."wdt:P709".-> v13 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c9 --"wikibase:language"--> c11 end bind5[/"?ca2_label"/] v4 --o bind5 bind5 --as--o v14