query-a5ad00fe4708946334aaf454105a70fc

rq turtle/ttl

Administrative tree for french communes is possible to have all the administrative levels of this commune? (Q193812)Ambléon Starting from a french commune ex. (Q1724443)canton of Belley Canton= (Q700647)arrondissement of Belley Arrondissement= (Q3083)Ain Departement= (Q18338206)Auvergne-Rhône-Alpes Region= 16:34, 8 May 2020 (UTC)) talk (ValterVBI need it to create all the pages about french communes in a little wiki. --17:37, 8 May 2020 (UTC) JuraFrench contributors of Wikidata tried to phase out the last (or the last to layers) from the "administrative" tree. The last ones should now be in electoral districts. Compared to other countries, the structure is somewhat hard to query as one needs to take in account end dates at various places. It might be easier to select with an identifier. --- Moment, I don't need a list because I work only one common by time , so is possible modify this query to have only actual data? 18:25, 8 May 2020 (UTC)) talk (ValterVBMaybe is better read this data directly from the pages of wikipedia in french. --

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 * WHERE {
{
SELECT DISTINCT ?item ?itemLabel ?lev ?levLabel ?tipoLev ?tipoLevLabel
WHERE {
  VALUES ?item { wd:Q193812 } #common item
  ?item wdt:P7938 ?canton.
  ?item wdt:P131+ ?lev.
  ?lev wdt:P31 ?tipoLev.  
  SERVICE wikibase:label { bd:serviceParam wikibase:language "fr". }
  FILTER (?tipoLev in (wd:Q36784,wd:Q6465,wd:Q194203)) #region, departement, arrondissement
}
}
UNION
{
SELECT DISTINCT ?item ?itemLabel ?lev ?levLabel ?tipoLev ?tipoLevLabel
WHERE {
  VALUES ?item { wd:Q193812 } #canton
  ?item wdt:P7938 ?lev.
  ?lev wdt:P31 ?tipoLev.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "fr". }
}
}
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v3("?canton") v5("?item"):::projected v4("?lev"):::projected v1("?tipoLev"):::projected c8(["bd:serviceParam"]):::iri c10(["fr"]):::literal subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; bind0[/VALUES ?item/] bind0-->v5 bind00(["wd:Q193812"]) bind00 --> bind0 v5 --"wdt:P7938"--> v4 v4 --"wdt:P31"--> v1 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c8 --"wikibase:language"--> c10 end end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; list0c1(["wd:Q36784"]):::iri list0c2(["wd:Q6465"]):::iri list0c3(["wd:Q194203"]):::iri list0c1 --o f1 list0c2 --o f1 list0c3 --o f1 f1[[" in "]] f1 --> v1 bind2[/VALUES ?item/] bind2-->v5 bind20(["wd:Q193812"]) bind20 --> bind2 v5 --"wdt:P7938"--> v3 v5 --"wdt:P131"--> v4 v4 --"wdt:P31"--> v1 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c8 --"wikibase:language"--> c10 end end union0r <== or ==> union0l end