Qualificatori
Let’s look again at the query about films with more than 5 nominations.
# Films that were nominated for more than 5 awards, and the count of nominations. SELECT ?item ?itemLabel (COUNT(DISTINCT ?award) AS ?count) WHERE { ?item wdt:P31/wdt:P279* wd:Q11424. # Item is instance of a film or subclass thereof ?item wdt:P1411 ?award. # Item was nominated for an award, collected by ?award SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". } } GROUP BY ?item ?itemLabel # The results are shown per film HAVING (?count>5) # Only films with more than 5 nominations ORDER BY DESC(?count) # In descending order
This query counts awards of any kind. How can we edit the query to show the films with most Academy award nominations?
We could specify that the award should be an instance of an Academy award:
However, some films could be nominated twice for the same award. For example, the film “All About Eve” (Q200299) had two nominations for Best Actress award:
If our query only relies on the “nominated for” property and its value then the two nominations would be identical statements and therefore counted only once.
If you have already learned how to query statements with qualifiers then you know that in the Wikidata data model, for every direct property linking an item and a value, there is also a simple property (p) that connects the item to a statement node. For each award nomination there is a different statement node. In order to retrieve the correct number of Academy award nominations per film the query needs to count for each film how many “nominated for” statement nodes there are for which the the value (i.e., the award) is an Academy award:
Now the query counts the award statements of awards that are an instance of an Academy award. Note that the nominees themselves are qualifiers to each award statement, but are not relevant to the count of the query.