query-9ad34d65b72fbd35f7f694cdc1d6b3c1
List mother organisation of an organisations set in wd
for each level, create a separate line as shown in the commented line 3
for avoyding mother organisation, of an organisation, you just skipi ?PO1stlevelLabel on the SELECT line
SELECT ?PO2ndlevelLabel # ?PO3rdlevelLabel WHERE { ?PO1stlevel wdt:P355 wd:Q1318441. ?PO2ndlevel wdt:P355 ?PO1stlevel.
?PO3rdlevel wdt:P355 ?PO2ndlevel.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". } }
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 bd: <http://www.bigdata.com/rdf#>
# List mother organisation of an organisations set in wd
# for each level, create a separate line as shown in the commented line 3
# for avoyding mother organisation, of an organisation, you just skipi ?PO1stlevelLabel on the SELECT line
SELECT ?PO2ndlevelLabel # ?PO3rdlevelLabel
WHERE
{
?PO1stlevel wdt:P355 wd:Q1318441.
?PO2ndlevel wdt:P355 ?PO1stlevel.
# ?PO3rdlevel wdt:P355 ?PO2ndlevel.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". }
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v1("?PO1stlevel")
v2("?PO2ndlevel")
c4(["bd:serviceParam"]):::iri
c6(["#91;AUTO_LANGUAGE#93;"]):::literal
c2(["wd:Q1318441"]):::iri
v1 --"wdt:P355"--> c2
v2 --"wdt:P355"--> v1
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c4 --"wikibase:language"--> c6
end