query-ec8e3d37000ccf096fa9ab6259840e0f
Video Games by Number of Cast Members
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item ?itemLabel ?languageLabel (count(?actor) as ?countActors) (count(?charName) as ?countCharsNames) (count(?charItem) as ?countCharItems)
WHERE
{
?item wdt:P31 wd:Q7889.
?item (p:P725|p:161) ?cast.
?cast (ps:P725|ps:161) ?actor.
optional{?cast pq:P4633 ?charName.}
optional{?cast pq:P453 ?charItem.}
optional{?cast pq:P407 ?language.}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } # Helps get the label in your language, if not, then en language
}
group by ?item ?itemLabel ?languageLabel
order by DESC(?countActors)
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v4("?actor"):::projected
v3("?cast")
v6("?charItem"):::projected
v5("?charName"):::projected
v8("?countActors")
v9("?countCharItems")
v8("?countCharsNames")
v2("?item"):::projected
v7("?language")
c11(["bd:serviceParam"]):::iri
c2(["wd:Q7889"]):::iri
c13(["#91;AUTO_LANGUAGE#93;,en"]):::literal
v2 --"p:direct/P31"--> c2
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
v2 --"p:161"--> v3
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v2 --"p:P725"--> v3
end
union0r <== or ==> union0l
end
subgraph union1[" Union "]
subgraph union1l[" "]
style union1l fill:#abf,stroke-dasharray: 3 3;
v3 --"p:statement/161"--> v4
end
subgraph union1r[" "]
style union1r fill:#abf,stroke-dasharray: 3 3;
v3 --"p:statement/P725"--> v4
end
union1r <== or ==> union1l
end
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v3 -."p:qualifier/P4633".-> v5
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v3 -."p:qualifier/P453".-> v6
end
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v3 -."p:qualifier/P407".-> v7
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c11 --"wikibase:language"--> c13
end
bind3[/"count(?actor)"/]
v4 --o bind3
bind3 --as--o v8
bind4[/"count(?charName)"/]
v5 --o bind4
bind4 --as--o v8
bind5[/"count(?charItem)"/]
v6 --o bind5
bind5 --as--o v9