Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Wikidata SPARQL query to retrieve films that have won the Palme d'Or at Cannes
SELECT
?film
?title
?directors
?year
WHERE
{
SELECT
?film
?title
(GROUP_CONCAT(?directorLabel; SEPARATOR=" & ") AS ?directors)
(STR(YEAR(?date)) AS ?year)
WHERE
{
# P31: instance of; P279: subclass of; Q11424: Film
?film wdt:P31/wdt:P279* wd:Q11424;
# P166: award received; Q179808: Palme d'Or; P585: point in time
p:P166 [ ps:P166 wd:Q179808; pq:P585 ?date ].
OPTIONAL {
# P57: director
?film wdt:P57 ?director
}
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en" .
?director rdfs:label ?directorLabel .
?film rdfs:label ?title
}
}
GROUP BY
?film
?title
?date
}
ORDER BY ?year
SELECT ?film (CONCAT("https://imdb.com/title/", ?imdbID) AS ?url) ?year ?title ?directors WHERE {
SELECT ?film ?title ?imdbID (GROUP_CONCAT(?directorLabel; SEPARATOR = " & ") AS ?directors) (STR(YEAR(?date)) AS ?year) WHERE {
?film (wdt:P31/(wdt:P279*)) wd:Q11424;
p:P166 ?award.
?award ps:P166 wd:Q179808;
pq:P585 ?date.
OPTIONAL { ?film wdt:P57 ?director. }
OPTIONAL { ?film wdt:P345 ?imdbID. }
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en".
?director rdfs:label ?directorLabel.
?film rdfs:label ?title.
}
}
GROUP BY ?film ?title ?date ?imdbID
}
ORDER BY DESC (?year)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.