query-847a24a65095d926b7283bf46a2ff288

rq turtle/ttl

MétropoleNombre : 1 277 (au 18/01/2023)

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
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/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT DISTINCT ?item ?itemLabel WHERE {
  { ?item wdt:P31/wdt:P279* wd:Q34442 ; p:P16/ps:P16 wd:Q1426271 } . 
  MINUS { VALUES ?outre_mer { wd:Q17012 wd:Q17054 wd:Q3769 wd:Q17070 wd:Q34617 wd:Q17063 wd:Q25362 wd:Q126125 } . ?item wdt:P131 ?outre_mer } . 
  OPTIONAL { ?item wdt:P1824 ?p1824 } 
  BIND(STRLEN(str(?p1824)) as ?longp1824) 
  BIND(SUBSTR(str(?p1824),1,1) as ?statut) 
  BIND(SUBSTR(str(?p1824),2,(?longp1824 - 1)) as ?numero) 
  BIND(REPLACE(SUBSTR(str(?numero),1,4),"[A-Za-z ]","") as ?num) 
  BIND(STRLEN(str(?num)) as ?longnum) 
  BIND(CONCAT(IF(?longnum=1,"000",IF(?longnum=2,"00",IF(?longnum=3,"0",""))), str(?num)) as ?numz) 
  BIND(CONCAT(str(?statut),str(?num)) as ?numsp) 
  BIND(STRLEN(str(?numsp)) as ?longnumsp) 
  BIND((?longp1824 - ?longnumsp) as ?longprefixe) 
  BIND(SUBSTR(str(?p1824),(?longnumsp + 1),?longprefixe) as ?prefixe) 
  BIND(CONCAT(str(?statut),str(?numz),str(?prefixe)) as ?cledetri) 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "fr" . } 
} ORDER BY ?cledetri

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v15("?cledetri") v2("?item"):::projected v9("?longnum") v12("?longnumsp") v5("?longp1824") v13("?longprefixe") v8("?num") v7("?numero") v11("?numsp") v10("?numz") v3("?outre_mer") v4("?p1824") v14("?prefixe") v6("?statut") a1((" ")) a2((" ")) c3(["wd:Q34442"]):::iri c10(["bd:serviceParam"]):::iri c6(["wd:Q1426271"]):::iri c12(["fr"]):::literal v2 --"p:direct/P31"--> a1 a1 --"p:direct/P279"--> c3 v2 --"p:P16"--> a2 a2 --"p:statement/P16"--> c6 subgraph minus0["MINUS"] style minus0 stroke-width:6px,fill:pink,stroke:red; bind1[/VALUES ?outre_mer/] bind1-->v3 bind10(["wd:Q17012"]) bind10 --> bind1 bind11(["wd:Q17054"]) bind11 --> bind1 bind12(["wd:Q3769"]) bind12 --> bind1 bind13(["wd:Q17070"]) bind13 --> bind1 bind14(["wd:Q34617"]) bind14 --> bind1 bind15(["wd:Q17063"]) bind15 --> bind1 bind16(["wd:Q25362"]) bind16 --> bind1 bind17(["wd:Q126125"]) bind17 --> bind1 v2 --"p:direct/P131"--> v3 end subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v2 -."p:direct/P1824".-> v4 end bind2[/"string-length(str(?p1824))"/] v4 --o bind2 bind2 --as--o v5 bind3[/"substring(str(?p1824),'1^^xsd:integer','1^^xsd:integer')"/] v4 --o bind3 bind3 --as--o v6 bind4[/"substring(str(?p1824),'2^^xsd:integer',?longp1824 - '1^^xsd:integer')"/] v4 --o bind4 v5 --o bind4 bind4 --as--o v7 bind5[/"replace(substring(str(?numero),'1^^xsd:integer','4^^xsd:integer'),'#91;A-Za-z #93;','')"/] v7 --o bind5 bind5 --as--o v8 bind6[/"string-length(str(?num))"/] v8 --o bind6 bind6 --as--o v9 bind7[/"concat(if(?longnum = '1^^xsd:integer','000',if(?longnum = '2^^xsd:integer','00',if(?longnum = '3^^xsd:integer','0',''))),str(?num))"/] v9 --o bind7 v8 --o bind7 bind7 --as--o v10 bind8[/"concat(str(?statut),str(?num))"/] v6 --o bind8 v8 --o bind8 bind8 --as--o v11 bind9[/"string-length(str(?numsp))"/] v11 --o bind9 bind9 --as--o v12 bind10[/"?longp1824 - ?longnumsp"/] v5 --o bind10 v12 --o bind10 bind10 --as--o v13 bind11[/"substring(str(?p1824),?longnumsp + '1^^xsd:integer',?longprefixe)"/] v4 --o bind11 v12 --o bind11 v13 --o bind11 bind11 --as--o v14 bind12[/"concat(str(?statut),str(?numz),str(?prefixe))"/] v6 --o bind12 v10 --o bind12 v14 --o bind12 bind12 --as--o v15 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c10 --"wikibase:language"--> c12 end