I'm trying to write a SPARQL query using Wikidata Query Service to retrieve all prime ministers of the Netherlands from 1970. However, I want to filter the output by checking if a prime minister worked for a university. If a minister worked for a university, it should not be in the output.
I think I must use the FILTER NOT EXISTS expression, but do not know how to properly write this line. Can someone please help me out?
See below for my query and output:
SELECT ?pmLabel ?start ?companyLabel
WHERE
{
?pm wdt:P39 wd:Q3058109.
?pm p:P39 ?posHeld.
?pm wdt:P108 ?company.
?posHeld ps:P39 wd:Q3058109.
?posHeld pq:P580 ?start.
FILTER(year(?start) > 1970)
# FILTER NOT EXISTS(?company (something) "Universit")
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } # labels
}
ORDER BY DESC(?start)
+----------------------+------------------+------------------------------+
| primeMinisterLabel | start | companyLabel |
+----------------------+------------------+------------------------------+
| Mark Rutte | 14 October 2010 | Unilever |
| Mark Rutte | 14 October 2010 | Calvé |
| Jan Peter Balkenende | 22 July 2002 | Erasmus University Rotterdam |
| Jan Peter Balkenende | 22 July 2002 | Vrije Universiteit Amsterdam |
| Ruud Lubbers | 4 November 1982 | United Nations |
| Ruud Lubbers | 4 November 1982 | Harvard University |
| Ruud Lubbers | 4 November 1982 | Tilburg University |
| Ruud Lubbers | 4 November 1982 | Hollandia |
| Dries van Agt | 19 December 1977 | Kyoto University |
| Dries van Agt | 19 December 1977 | Radboud University Nijmegen |
| Dries van Agt | 19 December 1977 | Kwansei Gakuin University |
| Dries van Agt | 19 December 1977 | Ritsumeikan University |
+----------------------+------------------+------------------------------+