query-6422ccf0c4f21a3d7a58b0421ece80bc

rq turtle/ttl

this time, allow the class to be used directly by the item's statement, but don't include it as a row

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 ?item ?itemLabel ?occLabel WHERE {
  ?item wdt:P106 ?occ.                 #item has an occ
  ?occ wdt:P279* wd:Q1930187 .         #occ is a subclass of journalist, or journalist
  filter(?occ not in (wd:Q1930187))    #don't include rows that equal "journalist", but the item's P106 ''may still have "journalist"''
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY ?itemLabel
LIMIT 100 # number of rows ~12000

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v3("?item"):::projected v1("?itemLabel"):::projected v2("?occ") c1(["wd:Q1930187"]):::iri c5(["bd:serviceParam"]):::iri c7(["#91;AUTO_LANGUAGE#93;,en"]):::literal f0[["?occ != 'wd:Q1930187'"]] f0 --> v2 v3 --"wdt:P106"--> v2 v2 --"wdt:P279"--> c1 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c5 --"wikibase:language"--> c7 end