query-f414a645b83fc0a78a12e1f737562445

rq turtle/ttl

Communes françaises SELECT DISTINCT ?commune ?commune_label ?insee { ?commune p:P31 ?typeStatement . # Les éléments qui ont pour nature... ?typeStatement ps:P31/wdt:P279* wd:Q484170 . # commune française ou une sous-classe FILTER NOT EXISTS { ?typeStatement pq:P582 [] } . # La commune n'a pas de date de fin

  ?commune p:P374 ?inseeStatement .
  ?inseeStatement ps:P374 ?insee .
  FILTER NOT EXISTS { ?inseeStatement pq:P582 [] } . # Le code insee n'a pas de date de fin

OPTIONAL { ?commune rdfs:label ?commune_label . FILTER (LANG(?commune_label) = "fr") . } }

Use at

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 ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
# Communes françaises
SELECT DISTINCT ?commune ?commune_label ?insee {
      ?commune p:P31 ?typeStatement . # Les éléments qui ont pour nature...
      ?typeStatement ps:P31/wdt:P279* wd:Q484170 . # commune française ou une sous-classe
      FILTER NOT EXISTS { ?typeStatement pq:P582 [] } . # La commune n'a pas de date de fin

      ?commune p:P374 ?inseeStatement .
      ?inseeStatement ps:P374 ?insee .
      FILTER NOT EXISTS { ?inseeStatement pq:P582 [] } . # Le code insee n'a pas de date de fin

  OPTIONAL { ?commune rdfs:label ?commune_label . FILTER (LANG(?commune_label) = "fr") . }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v4("?commune"):::projected v3("?commune_label"):::projected v5("?insee"):::projected v1("?inseeStatement") v2("?typeStatement") a2((" ")) a1((" ")) a3((" ")) c6(["wd:Q484170"]):::iri f0[["not "]] subgraph f0e0["Exists Clause"] e0v1 --"p:qualifier/P582"--> e0a1 e0v1("?inseeStatement"):::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("?typeStatement"):::projected e1a1((" ")):::projected end f1--EXISTS--> f1e1 f1 --> v2 f1 --> c1 f1 --> a2 v2 --"p:qualifier/P582"--> a2 v4 --"p:P31"--> v2 v2 --"p:statement/P31"--> a3 a3 --"p:direct/P279"--> c6 v4 --"p:P374"--> v1 v1 --"p:statement/P374"--> v5 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v4 -."rdfs:label".-> v3 end