query-634cc0984136ef72b095de49bcea0626
TODO
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT DISTINCT ?item ?itemLabel ?numdep WHERE {
?item wdt:P16 wd:Q19796778 .
?item wdt:P131 ?dep .
OPTIONAL { ?dep wdt:P2586 ?numdep }
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 } .
?item wdt:P609 [] .
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 ?numdep ?cledetri
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v17("?cledetri")
v4("?dep")
v3("?item"):::projected
v11("?longnum")
v14("?longnumsp")
v7("?longp1824")
v15("?longprefixe")
v10("?num")
v1("?numdep"):::projected
v9("?numero")
v13("?numsp")
v12("?numz")
v5("?outre_mer")
v6("?p1824")
v16("?prefixe")
v8("?statut")
a1((" "))
c8(["bd:serviceParam"]):::iri
c2(["wd:Q19796778"]):::iri
c10(["fr"]):::literal
v3 --"wdt:P16"--> c2
v3 --"wdt:P131"--> v4
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v4 -."wdt:P2586".-> v1
end
subgraph minus0["MINUS"]
style minus0 stroke-width:6px,fill:pink,stroke:red;
bind1[/VALUES ?outre_mer/]
bind1-->v5
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
v3 --"wdt:P131"--> v5
end
v3 --"wdt:P609"--> a1
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v3 -."wdt:P1824".-> v6
end
bind2[/"string-length(str(?p1824))"/]
v6 --o bind2
bind2 --as--o v7
bind3[/"substring(str(?p1824),'1^^xsd:integer','1^^xsd:integer')"/]
v6 --o bind3
bind3 --as--o v8
bind4[/"substring(str(?p1824),'2^^xsd:integer',?longp1824 - '1^^xsd:integer')"/]
v6 --o bind4
v7 --o bind4
bind4 --as--o v9
bind5[/"replace(substring(str(?numero),'1^^xsd:integer','4^^xsd:integer'),'#91;A-Za-z #93;','')"/]
v9 --o bind5
bind5 --as--o v10
bind6[/"string-length(str(?num))"/]
v10 --o bind6
bind6 --as--o v11
bind7[/"concat(if(?longnum = '1^^xsd:integer','000',if(?longnum = '2^^xsd:integer','00',if(?longnum = '3^^xsd:integer','0',''))),str(?num))"/]
v11 --o bind7
v10 --o bind7
bind7 --as--o v12
bind8[/"concat(str(?statut),str(?num))"/]
v8 --o bind8
v10 --o bind8
bind8 --as--o v13
bind9[/"string-length(str(?numsp))"/]
v13 --o bind9
bind9 --as--o v14
bind10[/"?longp1824 - ?longnumsp"/]
v7 --o bind10
v14 --o bind10
bind10 --as--o v15
bind11[/"substring(str(?p1824),?longnumsp + '1^^xsd:integer',?longprefixe)"/]
v6 --o bind11
v14 --o bind11
v15 --o bind11
bind11 --as--o v16
bind12[/"concat(str(?statut),str(?numz),str(?prefixe))"/]
v8 --o bind12
v12 --o bind12
v16 --o bind12
bind12 --as--o v17
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c8 --"wikibase:language"--> c10
end