query-b9c80f4b848dce06dcac493fe8ed0ab4

rq turtle/ttl

Identifiers on an administrative territorial entity not matching the idenfier of the entity above (only based the first 3 characters for now, some false-positive for oversea territories) SELECT ?q1 (GROUP_CONCAT(DISTINCT ?id1) as ?id1s) (GROUP_CONCAT(DISTINCT ?q2) as ?q2s) (GROUP_CONCAT(DISTINCT ?id2) as ?id2s) WHERE { ?q1 wdt:P8714 ?id1 . ?q1 wdt:P31/wdt:P279 wd:Q56061 . ?q1 wdt:P131 ?q2 . ?q2 wdt:P8714 ?id2 . FILTER (!REGEX(?id1,CONCAT(substr(?id2,1,IF(strlen(?id2)>3,strlen(?id2)-2,3)),"(\.\d)(","_1",")?"))) } GROUP BY ?q1

Use at

PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
#Identifiers on an administrative territorial entity not matching the idenfier of the entity above (only based the first 3 characters for now, some false-positive for oversea territories)
SELECT ?q1 (GROUP_CONCAT(DISTINCT ?id1) as ?id1s) (GROUP_CONCAT(DISTINCT ?q2) as ?q2s) (GROUP_CONCAT(DISTINCT ?id2) as ?id2s) WHERE {
  ?q1 wdt:P8714 ?id1 .
  ?q1 wdt:P31/wdt:P279* wd:Q56061 .
  ?q1 wdt:P131 ?q2 .
  ?q2 wdt:P8714 ?id2 .
  FILTER (!REGEX(?id1,CONCAT(substr(?id2,1,IF(strlen(?id2)>3,strlen(?id2)-2,3)),"(\\.\\d*)(","_1",")?")))
}
GROUP BY ?q1

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v1("?id1"):::projected v5("?id1s") v2("?id2"):::projected v7("?id2s") v3("?q1"):::projected v4("?q2"):::projected v6("?q2s") a1((" ")) c10(["wd:Q56061"]):::iri f0[["not regex(?id1,concat(substring(?id2,'1^^xsd:integer',if(string-length(?id2) > '3^^xsd:integer',string-length(?id2) + '-2^^xsd:integer','3^^xsd:integer')),'(\.\d*)(','_1',')?'))"]] f0 --> v1 f0 --> v2 v3 --"wdt:P8714"--> v1 v3 --"wdt:P31"--> a1 a1 --"wdt:P279"--> c10 v3 --"wdt:P131"--> v4 v4 --"wdt:P8714"--> v2 bind4[/"?id1"/] v1 --o bind4 bind4 --as--o v5 bind5[/"?q2"/] v4 --o bind5 bind5 --as--o v6 bind6[/"?id2"/] v2 --o bind6 bind6 --as--o v7