query-64a8fd73c4a221f7ed2a0d1e0a06ca39
Royal Navy ship names with official names as well
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 rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT DISTINCT ?label ?item ?en_label WHERE {
SERVICE wikibase:label { bd:serviceParam wikibase:language "en-gb,en,mul". }
{
SELECT DISTINCT ?item ?label ?en_label WHERE {
?item p:P31 ?statement0.
?statement0 (ps:P31/(wdt:P279*)) wd:Q11446.
?item p:P137 ?statement1.
?statement1 (ps:P137/(wdt:P279*)) wd:Q172771.
OPTIONAL {?item wdt:P1448 ?officialname}
OPTIONAL {?item rdfs:label ?en_label . FILTER(LANG(?en_label) = "en")}
BIND(COALESCE (?officialname, ?en_label) AS ?label)
}
}
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v1("?en_label"):::projected
v2("?item"):::projected
v6("?label"):::projected
v5("?officialname")
v3("?statement0")
v4("?statement1")
a1((" "))
a2((" "))
c4(["en-gb,en,mul"]):::literal
c2(["bd:serviceParam"]):::iri
c9(["wd:Q11446"]):::iri
c12(["wd:Q172771"]):::iri
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c2 --"wikibase:language"--> c4
end
v2 --"p:P31"--> v3
v3 --"p:statement/P31"--> a1
a1 --"p:direct/P279"--> c9
v2 --"p:P137"--> v4
v4 --"p:statement/P137"--> a2
a2 --"p:direct/P279"--> c12
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v2 -."p:direct/P1448".-> v5
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v2 -."rdfs:label".-> v1
end
bind0[/"?officialname?en_label"/]
v5 --o bind0
v1 --o bind0
bind0 --as--o v6