query-59b30baca622439c61c98afffb93d4a4
Find country of shipyard that built a ship
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 ps: <http://www.wikidata.org/prop/statement/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT DISTINCT ?item ?itemLabel ?shipyardLabel ?country ?countryLabel WHERE {
SERVICE wikibase:label { bd:serviceParam wikibase:language "en-gb,en,mul". }
{
SELECT DISTINCT ?item ?country ?shipyard WHERE {
?item p:P31 ?statement0.
?statement0 (ps:P31/(wdt:P279*)) wd:Q559026.
MINUS {
?item p:P495 ?statement1.
?statement1 (ps:P495/(wdt:P279*)) _:anyValueP495.
}
?item wdt:P176 ?shipyard.
?shipyard wdt:P17 ?country.
}
}
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v5("?country"):::projected
v1("?item"):::projected
v4("?shipyard")
v2("?statement0")
v3("?statement1")
a3((" "))
a1((" "))
a2((" "))
c4(["en-gb,en,mul"]):::literal
c2(["bd:serviceParam"]):::iri
c8(["wd:Q559026"]):::iri
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c2 --"wikibase:language"--> c4
end
v1 --"p:P31"--> v2
v2 --"p:statement/P31"--> a1
a1 --"p:direct/P279"--> c8
subgraph minus0["MINUS"]
style minus0 stroke-width:6px,fill:pink,stroke:red;
v1 --"p:P495"--> v3
v3 --"p:statement/P495"--> a2
a2 --"p:direct/P279"--> a3
end
v1 --"p:direct/P176"--> v4
v4 --"p:direct/P17"--> v5