query-89247f724a65213038d24f7d06edb42f

rq turtle/ttl

Communes de FranceBonjour, La requête suivante donne la liste des communes françaises existant au 1er janvier 2017, triées par leur code INSEE.

Use at

PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX p: <http://www.wikidata.org/prop/>
SELECT ?insee ?commune
WHERE {
  BIND ( "2017-01-01"^^xsd:date as ?dateRecherche )        # date recherchée
  ?commune wdt:P374 ?insee.                                   # code INSEE
  ?commune p:P31 ?nature.
  {?nature ps:P31 wd:Q484170.}                           # commune de France
  UNION { ?nature ps:P31 wd:Q22927616. }                   # commune française à statut particulier
  OPTIONAL { ?commune wdt:P571 ?dateCréation. }                  # date création
  OPTIONAL { ?commune wdt:P576 ?dateDissolution. }                    # date dissolution
  FILTER ( !BOUND(?dateCréation)|| ?dateCréation <= ?dateRecherche ) # communes futures
  FILTER ( !BOUND(?dateDissolution)|| ?dateDissolution > ?dateRecherche )      # communes passées
  FILTER ( !STRSTARTS(?insee, "98") )                      # - Polynésie
  FILTER ( !STRSTARTS(?insee, "975") )                     # - Saint-Pierre et Miquelon
}
ORDER BY (?insee)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v5("?commune"):::projected v4("?dateCréation") v2("?dateDissolution") v5("?dateRecherche") v1("?insee"):::projected v6("?nature") c7(["wd:Q22927616"]):::iri c6(["wd:Q484170"]):::iri f0[["not starts-with(?insee,'975')"]] f0 --> v1 f1[["not starts-with(?insee,'98')"]] f1 --> v1 f2[["(not bound(?dateDissolution) || ?dateDissolution > ?dateRecherche)"]] f2 --> v2 f2 --> v5 f3[["(not bound(?dateCréation) || ?dateCréation <= ?dateRecherche)"]] f3 --> v4 f3 --> v5 bind4[/"'2017-01-01^^xsd:date'"/] bind4 --as--o v5 v5 --"p:direct/P374"--> v1 v5 --"p:P31"--> v6 subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; v6 --"p:statement/P31"--> c7 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v6 --"p:statement/P31"--> c6 end union0r <== or ==> union0l end subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v5 -."p:direct/P571".-> v4 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v5 -."p:direct/P576".-> v2 end