i am very new to sparql and i am trying to run 3 queries on wikidata:
- Persons who are not painters and who are students of painters.
- Persons who are not painters and who are academic offspring or children of painters (note: an academic offspring of a person
P
is somebody who is/was a student ofP
, or a student of a student ofP
, or .... ). - People who are academic offspring of themselves.
i got stuck on the first one, i tried:
SELECT DISTINCT ?human ?humanLabel WHERE {
?human wdt:P31 wd:Q5.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
?human wikibase:statements ?statementcount.
?human wdt:P106 ?profession.
FILTER(?profession != wd:Q1028181)
FILTER(?statementcount > 50 )
?human wdt:P1066 ?teacher.
?teacher wdt:P106 ?tprofession.
FILTER(?tprofession = wd:Q1028181)
OPTIONAL { }
}LIMIT 50
but i think in this line: FILTER(?profession != wd:Q1028181)
, is not checking all the professions against painter but just the first one, so i get painters that have multiple occupations in the output because is checking just the first occupation against painter, but i want all those occupations checked against painter.