query-eebdc7aa974cc0d6035479a8bde42200
Propertiesinstance of (P31)subclass of (P279)twinned administrative body (P190)
Use at
- https://query.wikidata.org/sparql
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
SELECT DISTINCT ?sister_city_qid ("P190" as ?P190) ?city_qid
WHERE {
?city wdt:P31/wdt:P279* wd:Q515.
?city wdt:P190 ?sister_city.
BIND(SUBSTR(STR(?city), STRLEN(STR(wd:)) + 1) AS ?city_qid).
BIND(SUBSTR(STR(?sister_city), STRLEN(STR(wd:)) + 1) AS ?sister_city_qid)
FILTER(NOT EXISTS { ?sister_city wdt:P190 ?city. })
}
ORDER BY ?city
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v5("?P190")
v1("?city")
v3("?city_qid"):::projected
v2("?sister_city")
v4("?sister_city_qid"):::projected
a1((" "))
c4(["wd:Q515"]):::iri
f0[["not "]]
subgraph f0e0["Exists Clause"]
e0v1 --"wdt:P190"--> e0v2
e0v2("?city"):::projected
e0v1("?sister_city"):::projected
end
f0--EXISTS--> f0e0
f0 --> v2
f0 --> c1
f0 --> v1
v2 --"wdt:P190"--> v1
v1 --"wdt:P31"--> a1
a1 --"wdt:P279"--> c4
v1 --"wdt:P190"--> v2
bind1[/"substring(str(?city),string-length(str('wd:')) + '1^^xsd:integer')"/]
v1 --o bind1
bind1 --as--o v3
bind2[/"substring(str(?sister_city),string-length(str('wd:')) + '1^^xsd:integer')"/]
v2 --o bind2
bind2 --as--o v4
bind3[/"'P190'"/]
bind3 --as--o v5