Користувач:Gz260/Дороги/E/Wikidata
? : середа 13 листопад 2024 23:55:24
SPARQL-запит (виконати • довідка Wikidata Query • TABernacle · old):
SELECT ?item ?p1824 ?longnum ?count WHERE { { ?item wdt:P16 wd:Q106123 . } UNION { ?item wdt:P31 wd:Q106123 . } . MINUS { ?item wdt:P361 ?part . ?part wdt:P16 wd:Q106123 } . 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) . OPTIONAL { SELECT ?item (COUNT(?pays) as ?count) WHERE { { ?item wdt:P16 wd:Q106123 . } UNION { ?item wdt:P31 wd:Q106123 . } . ?item wdt:P17 ?pays . } GROUP BY ?item } . } ORDER BY ?cledetri ?longnum DESC(?count)