query-4b4b1585043280d75c35e4cbba92595c
TODO
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT distinct ?item ?itemLabel ?countryLabel ?designation_countryLabel ?coords
where {
{
Select ?item (count(?item) as ?count) # this select gets us items with more than one country / heritage designation
where {
?item wdt:P1435 ?designation. # item has a heritage designation
?item wdt:P17 ?country. # item has a country
?designation wdt:P17 ?designation_country. # the heritage designation has a country
filter (?country!=?designation_country) # the country of the heritage designation is not the listing country
} group by ?item having (?count>1) } # this select finds properties of the items found in the last select
?item wdt:P1435 ?designation. # item has a heritage designation
?item wdt:P17 ?country. # item has a country
?designation wdt:P17 ?designation_country. # the heritage designation has a country
OPTIONAL {?item wdt:P625 ?coords.} # item may have coordinates
filter (?country!=?designation_country) # the country of the heritage designation is not the listing country
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} order by ?itemLabel ?countryLabel ?designationLabel
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v9("?coords"):::projected
v9("?count")
v4("?country")
v2("?countryLabel"):::projected
v8("?designation")
v3("?designationLabel")
v5("?designation_country")
v7("?item"):::projected
v1("?itemLabel"):::projected
c6(["bd:serviceParam"]):::iri
c8(["#91;AUTO_LANGUAGE#93;,en"]):::literal
f0[["?country != ?designation_country"]]
f0 --> v4
f0 --> v5
f1[["?count > '1^^xsd:integer'"]]
f1 --> v9
f2[["?country != ?designation_country"]]
f2 --> v4
f2 --> v5
v7 --"wdt:P1435"--> v8
v7 --"wdt:P17"--> v4
v8 --"wdt:P17"--> v5
bind4[/"count(?item)"/]
v7 --o bind4
bind4 --as--o v9
v7 --"wdt:P1435"--> v8
v7 --"wdt:P17"--> v4
v8 --"wdt:P17"--> v5
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v7 -."wdt:P625".-> v9
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c6 --"wikibase:language"--> c8
end