query-729a1f4d1401b4b184232d029bcb7ef4

rq turtle/ttl

Multi-level localisation 15:12, 28 May 2019 (UTC) B Yanik name of an entity. --(Q55998242)administrative region of Quebec name and the (Q204613)regional county municipality . What would be the query to list the municipality name, the (Q764294)Centre-du-Québec who has P131 (Q1261297)Drummond have P131 (Q141940)Drummondville may be a lower level entity, how can we show upper level entities ? For example, (P131)located in the administrative territorial entity Since } } "en" language:wikibase serviceParam:bd { label:wikibase SERVICE .?county P131:wdt ?item . ?region P131:wdt ?county .Q204613:wd P31:wdt ?county . Q55998242:wd P31:wdt ?region } Q141940:wd { ?item VALUES { WHERE ?regionLabel ?region ?countyLabel ?county ?itemLabel ?item SELECT 11:16, 29 May 2019 (UTC) B Yanik: Well done ! Very interresting those "". Thank's a lot. --99of9@ 07:16, 29 May 2019 (UTC)) talk (99of9: see if this fits your requirements. --YanikB@I tried to add a level but it does't work. } } "en" language:wikibase serviceParam:bd { label:wikibase SERVICE . ?mun P131:wdt ?item . ?county P131:wdt ?mun . ?region P131:wdt ?county . Q3327873:wd P31:wdt ?mun .Q204613:wd P31:wdt ?county . Q55998242:wd P31:wdt ?region . Q16:wd P17:wdt ?item . Q1550557:wd P31:wdt ?item { WHERE ?regionLabel ?countyLabel ?munLabel ?itemLabel ?item SELECT 11:38, 31 May 2019 (UTC) B Yanik --

Use at

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#>
SELECT DISTINCT ?item ?itemLabel ?mun ?munLabel ?county ?countyLabel ?region ?regionLabel 
WHERE
{
  ?item wdt:P31/wdt:P279* wd:Q486972 .
  ?item wdt:P17 wd:Q16 .

  ?item wdt:P131/wdt:P131* ?mun .
  ?mun wdt:P31/wdt:P279* wd:Q3327873 .

  OPTIONAL
  {
    ?mun wdt:P131/wdt:P131* ?county .
    ?county wdt:P31/wdt:P279* wd:Q204613.
  }
  OPTIONAL
  { 
      ?mun wdt:P131/wdt:P131* ?region .
      ?region wdt:P31/wdt:P279* wd:Q55998242 .
  }
  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; v3("?county"):::projected v1("?item"):::projected v2("?mun"):::projected v4("?region"):::projected a1((" ")) a2((" ")) a3((" ")) a4((" ")) a5((" ")) a6((" ")) a7((" ")) c9(["wd:Q55998242"]):::iri c8(["wd:Q204613"]):::iri c3(["wd:Q486972"]):::iri c5(["wd:Q16"]):::iri c7(["wd:Q3327873"]):::iri c11(["bd:serviceParam"]):::iri c13(["#91;AUTO_LANGUAGE#93;,en"]):::literal v1 --"wdt:P31"--> a1 a1 --"wdt:P279"--> c3 v1 --"wdt:P17"--> c5 v1 --"wdt:P131"--> a2 a2 --"wdt:P131"--> v2 v2 --"wdt:P31"--> a3 a3 --"wdt:P279"--> c7 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v2 -."wdt:P131".-> a4 a4 --"wdt:P131"--> v3 v3 --"wdt:P31"--> a5 a5 --"wdt:P279"--> c8 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v2 -."wdt:P131".-> a6 a6 --"wdt:P131"--> v4 v4 --"wdt:P31"--> a7 a7 --"wdt:P279"--> c9 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c11 --"wikibase:language"--> c13 end