query-e70d85d5f43c151264c1ef457aa029b1

rq turtle/ttl

Au 1er janvier 2011, il y avait 36 680 communes en France. SELECT ?insee ?commune ?nom WHERE { BIND ( "2011-01-01"^^xsd:dateTime as ?dateRecherche ) # Au 1er janvier 2011 ?commune p:P374 ?P374node . # existence d'un code Insee ?P374node ps:P374 ?insee . # valeur du code Insee OPTIONAL { ?P374node pq:P580 ?dateDébutCode . } # date de début du code Insee OPTIONAL { ?P374node pq:P582 ?dateFinCode . } # date de fin du code Insee FILTER ( !BOUND(?dateDébutCode) || ?dateDébutCode <= ?dateRecherche ) # ancien code Insee FILTER ( !BOUND(?dateFinCode) || ?dateFinCode > ?dateRecherche ) # futur code Insee { ?commune wdt:P31 wd:Q484170 . } UNION { VALUES ?commune {wd:Q90} } # nature de commune OPTIONAL { ?commune wdt:P571 ?dateCréation . } # date de création OPTIONAL { ?commune wdt:P576 ?dateDissolution . } # date de dissolution FILTER ( !BOUND(?dateCréation) || ?dateCréation <= ?dateRecherche ) # communes futures FILTER ( !BOUND(?dateDissolution) || ?dateDissolution > ?dateRecherche ) # communes passées ?commune p:P1448 ?P1448node . # existence d'un nom ?P1448node ps:P1448 ?nom . # valeur du nom FILTER( lang(?nom)="fr" ). # nom en français MINUS { ?P1448node pq:P2241 ?dépréciationNom . } # nom erroné OPTIONAL { ?P1448node pq:P580 ?dateDébutNom . } # date de début du nom OPTIONAL { ?P1448node pq:P582 ?dateFinNom . } # date de fin du nom FILTER ( !BOUND(?dateDébutNom) || ?dateDébutNom <= ?dateRecherche ) # ancien nom FILTER ( !BOUND(?dateFinNom) || ?dateFinNom > ?dateRecherche ) # futur nom } ORDER BY (?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 pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
# Au 1er janvier 2011, il y avait 36 680 communes en France.
SELECT ?insee ?commune ?nom
WHERE {
  BIND ( "2011-01-01"^^xsd:date as ?dateRecherche ) # Au 1er janvier 2011
  ?commune p:P374 ?P374node . # existence d'un code Insee
    ?P374node ps:P374 ?insee . # valeur du code Insee
    OPTIONAL { ?P374node pq:P580 ?dateDébutCode . } # date de début du code Insee
    OPTIONAL { ?P374node pq:P582 ?dateFinCode . } # date de fin du code Insee
    FILTER ( !BOUND(?dateDébutCode) || ?dateDébutCode <= ?dateRecherche ) # ancien code Insee
    FILTER ( !BOUND(?dateFinCode) || ?dateFinCode > ?dateRecherche ) # futur code Insee
  { ?commune wdt:P31 wd:Q484170 . } UNION { VALUES ?commune {wd:Q90} } # nature de commune
    OPTIONAL { ?commune wdt:P571 ?dateCréation . } # date de création
    OPTIONAL { ?commune wdt:P576 ?dateDissolution . } # date de dissolution
    FILTER ( !BOUND(?dateCréation) || ?dateCréation <= ?dateRecherche ) # communes futures
    FILTER ( !BOUND(?dateDissolution) || ?dateDissolution > ?dateRecherche ) # communes passées
  ?commune p:P1448 ?P1448node . # existence d'un nom
    ?P1448node ps:P1448 ?nom . # valeur du nom
    FILTER( lang(?nom)="fr" ). # nom en français
    MINUS { ?P1448node pq:P2241 ?dépréciationNom . } # nom erroné
    OPTIONAL { ?P1448node pq:P580 ?dateDébutNom . } # date de début du nom
    OPTIONAL { ?P1448node pq:P582 ?dateFinNom . } # date de fin du nom
    FILTER ( !BOUND(?dateDébutNom) || ?dateDébutNom <= ?dateRecherche ) # ancien nom
    FILTER ( !BOUND(?dateFinNom) || ?dateFinNom > ?dateRecherche ) # futur nom
}
ORDER BY (?insee)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v12("?P1448node") v11("?P374node") v12("?commune"):::projected v7("?dateCréation") v6("?dateDissolution") v9("?dateDébutCode") v4("?dateDébutNom") v8("?dateFinCode") v2("?dateFinNom") v10("?dateRecherche") v13("?dépréciationNom") v1("?insee"):::projected v5("?nom"):::projected c7(["wd:Q484170"]):::iri f0[["(not bound(?dateFinNom) || ?dateFinNom > ?dateRecherche)"]] f0 --> v2 f0 --> v10 f1[["(not bound(?dateDébutNom) || ?dateDébutNom <= ?dateRecherche)"]] f1 --> v4 f1 --> v10 f2[["?nom = 'fr'"]] f2 --> v5 f3[["(not bound(?dateDissolution) || ?dateDissolution > ?dateRecherche)"]] f3 --> v6 f3 --> v10 f4[["(not bound(?dateCréation) || ?dateCréation <= ?dateRecherche)"]] f4 --> v7 f4 --> v10 f5[["(not bound(?dateFinCode) || ?dateFinCode > ?dateRecherche)"]] f5 --> v8 f5 --> v10 f6[["(not bound(?dateDébutCode) || ?dateDébutCode <= ?dateRecherche)"]] f6 --> v9 f6 --> v10 bind7[/"'2011-01-01^^xsd:date'"/] bind7 --as--o v10 v12 --"p:P374"--> v11 v11 --"p:statement/P374"--> v1 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v11 -."p:qualifier/P580".-> v9 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v11 -."p:qualifier/P582".-> v8 end subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; bind8[/VALUES ?commune/] bind8-->v12 bind80(["wd:Q90"]) bind80 --> bind8 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v12 --"p:direct/P31"--> c7 end union0r <== or ==> union0l end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v12 -."p:direct/P571".-> v7 end subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v12 -."p:direct/P576".-> v6 end v12 --"p:P1448"--> v12 v12 --"p:statement/P1448"--> v5 subgraph minus9["MINUS"] style minus9 stroke-width:6px,fill:pink,stroke:red; v12 --"p:qualifier/P2241"--> v13 end subgraph optional4["(optional)"] style optional4 fill:#bbf,stroke-dasharray: 5 5; v12 -."p:qualifier/P580".-> v4 end subgraph optional5["(optional)"] style optional5 fill:#bbf,stroke-dasharray: 5 5; v12 -."p:qualifier/P582".-> v2 end