query-48f41aef596e7e3e2150e8fa33eaa228

rq turtle/ttl

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

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

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v1("?item"):::projected a1((" ")) c2(["wd:Q1930187"]):::iri c5(["bd:serviceParam"]):::iri c7(["#91;AUTO_LANGUAGE#93;,en"]):::literal f0[["not "]] subgraph f0e0["Exists Clause"] e0v1 --"wdt:P106"--> e0c2 e0v1("?item"):::projected e0c2(["wd:Q1930187"]):::iri end f0--EXISTS--> f0e0 f0 --> v1 f0 --> c1 f0 --> c2 v1 --"wdt:P106"--> c2 v1 --"wdt:P106"--> a1 a1 --"wdt:P279"--> c2 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c5 --"wikibase:language"--> c7 end