query-6dcbbba99cd8b751a211df9a649f1257

rq turtle/ttl

Propertiesinstance of (P31)located in the administrative territorial entity (P131)end time (P582)

Use at

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/>
SELECT  ?commune ?departement WHERE {
  ?commune p:P31 ?communeStatement . # les trucs qui sont potentiellement
  ?communeStatement ps:P31 ?type . # ...un des types autorisés ci-dessous
  VALUES ?type {
    wd:Q484170 # commune française
    wd:Q2989454 # commune nouvelle
    wd:Q22927616 # commune française à statut particulier
  }
  FILTER NOT EXISTS {
    ?communeStatement pq:P582 [] . # mais alors vraiment des communes pur cru, sans date de fin
  }
  ?commune p:P131 ?communeDepartementStatement . # qui sont dans un département
  ?communeDepartementStatement ps:P131 ?departement . 
  FILTER NOT EXISTS { # mais qui y sont sans date de fin
    ?communeDepartementStatement pq:P582 [] .
  }
  ?departement p:P31 ?departementExistsStatement .
  FILTER NOT EXISTS {
    ?departementExistsStatement pq:P582 [] . # un département sans date de fin 
  }
  ?departementExistsStatement ps:P31 ?departementType .
  VALUES ?departementType {
    wd:Q6465 # département de France métropolitaine
    wd:Q28332 # ou ultramarin
  }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v4("?commune"):::projected v2("?communeDepartementStatement") v3("?communeStatement") v6("?departement"):::projected v1("?departementExistsStatement") v8("?departementType") v6("?type") a3((" ")) a2((" ")) a1((" ")) f0[["not "]] subgraph f0e0["Exists Clause"] e0v1 --"p:qualifier/P582"--> e0a1 e0v1("?departementExistsStatement"):::projected e0a1((" ")):::projected end f0--EXISTS--> f0e0 f0 --> v1 f0 --> c1 f0 --> a1 v1 --"p:qualifier/P582"--> a1 f1[["not "]] subgraph f1e1["Exists Clause"] e1v1 --"p:qualifier/P582"--> e1a1 e1v1("?communeDepartementStatement"):::projected e1a1((" ")):::projected end f1--EXISTS--> f1e1 f1 --> v2 f1 --> c1 f1 --> a2 v2 --"p:qualifier/P582"--> a2 f2[["not "]] subgraph f2e2["Exists Clause"] e2v1 --"p:qualifier/P582"--> e2a1 e2v1("?communeStatement"):::projected e2a1((" ")):::projected end f2--EXISTS--> f2e2 f2 --> v3 f2 --> c1 f2 --> a3 v3 --"p:qualifier/P582"--> a3 v4 --"p:P31"--> v3 v3 --"p:statement/P31"--> v6 bind3[/VALUES ?type/] bind3-->v6 bind30(["wd:Q484170"]) bind30 --> bind3 bind31(["wd:Q2989454"]) bind31 --> bind3 bind32(["wd:Q22927616"]) bind32 --> bind3 v4 --"p:P131"--> v2 v2 --"p:statement/P131"--> v6 v6 --"p:P31"--> v1 v1 --"p:statement/P31"--> v8 bind4[/VALUES ?departementType/] bind4-->v8 bind40(["wd:Q6465"]) bind40 --> bind4 bind41(["wd:Q28332"]) bind41 --> bind4