query-dd8fedaf50b1d1f9472e8e61e51d12f2
Age of actors distributed by genderHello, i have written the following query which gives me the age actors had when they played in a movie, distributed by age :
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 bd: <http://www.bigdata.com/rdf#>
SELECT ?genreLabel ?age (COUNT(*) as ?NB) WHERE {
?actor wdt:P569 ?dob .
?actor wdt:P21 ?genre .
?actor wdt:P106 wd:Q33999 .
# ?movie wdt:P495 wd:Q142 .
?actor wdt:P27 wd:Q142 .
?movie wdt:P161 ?actor .
?movie wdt:P577 ?dateMovie .
BIND(YEAR(?dateMovie)-YEAR(?dob) as ?age) .
FILTER(?age > 0) .
FILTER(?age < 100) .
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],fr". }
}
GROUP BY ?genreLabel ?age
ORDER BY ?age
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v7("?NB")
v2("?actor")
v7("?age"):::projected
v6("?dateMovie")
v3("?dob")
v4("?genre")
v5("?movie")
c12(["bd:serviceParam"]):::iri
c14(["#91;AUTO_LANGUAGE#93;,fr"]):::literal
c6(["wd:Q33999"]):::iri
c8(["wd:Q142"]):::iri
f0[["?age < '100^^xsd:integer'"]]
f0 --> v7
f1[["?age > '0^^xsd:integer'"]]
f1 --> v7
v2 --"wdt:P569"--> v3
v2 --"wdt:P21"--> v4
v2 --"wdt:P106"--> c6
v2 --"wdt:P27"--> c8
v5 --"wdt:P161"--> v2
v5 --"wdt:P577"--> v6
bind2[/"year-from-dateTime(?dateMovie) - year-from-dateTime(?dob)"/]
v6 --o bind2
v3 --o bind2
bind2 --as--o v7
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c12 --"wikibase:language"--> c14
end
bind4[/"count(*)"/]
bind4 --as--o v7