Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lisongx/0fcda7247c7f7d9b78412b3cb5416268 to your computer and use it in GitHub Desktop.
Save lisongx/0fcda7247c7f7d9b78412b3cb5416268 to your computer and use it in GitHub Desktop.
Directors with longer film duration
SELECT ?item ?cLabel ?itemLabel ?fatherLabel ?motherLabel
WHERE
{
?item wdt:P31 wd:Q5.
?item wdt:P27 ?c.
?item wdt:P22 ?father.
?item wdt:P25 ?mother.
?item wdt:P106 wd:Q2526255.
?father wdt:P106 wd:Q2526255.
?mother wdt:P106 wd:Q2526255.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
# The Chinese Film Director whose films have the longest avg duration
SELECT ?director ?directorLabel (COUNT(?film) as ?count) (AVG(?duration) AS ?avg_dur)
{
VALUES (?country) { ( wd:Q148 ) ( wd:Q29520 ) (wd:Q865)}
# VALUES (?country) { ( wd:Q17)}
?director wdt:P27 ?country.
# FILTER(?country IN (wd:Q148 wd:Q29520 wd:Q865)).
?film wdt:P31 wd:Q11424.
?film wdt:P57 ?director.
?film wdt:P2047 ?duration.
SERVICE wikibase:label { # ... include the labels
bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en"
}
} GROUP BY ?director ?directorLabel
ORDER BY DESC(?avg_dur)
SELECT ?item ?itemLabel ?itemdesc
WHERE
{
?item wdt:P31 wd:Q5.
?item wdt:P106/wdt:P279* wd:Q2526255.
FILTER(NOT EXISTS {
?item schema:description ?itemdesc.
FILTER(LANG(?itemdesc) = "zh")
})
SERVICE wikibase:label { bd:serviceParam wikibase:language "zh". }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment