query-48f41aef596e7e3e2150e8fa33eaa228
obtain label of subclasses of the selection, while excluding the starting class of the occupation statements, but one or more subclasses of journalist do appear; the second would not be so fussy (journalist may appear on another statement, but I only want the statement(s) that are subclasses of journalist). I would appreciate both versions, for learning, if possible. any journalist itself—while excluding any other occupation statements that the item has. There are two variants of this: one would ensure that "journalist" itself does not appear on but notI am new to SPARQL and I'm trying to figure out how to retrieve all items with, for example, an occupation that is a subclass of "journalist" I am working from the following. At root, I can't figure out how to fill in "occLabel" (which will contain things like "photojournalist", "reporter"--subclasses of "journalist" but not "journalist").
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#>
SELECT distinct ?item ?itemLabel ?occLabel WHERE {
?item wdt:P106/wdt:P279* wd:Q1930187 .
FILTER NOT EXISTS {?item wdt:P106 wd:Q1930187 }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
LIMIT 100