query-e1accd952deed801b52367e73743444d
TODO
Use at
- https://query.wikidata.org/sparql
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX p: <http://www.wikidata.org/prop/>
SELECT ?age (sum(?countmale) as ?male) (sum(?countfemale) as ?female) WHERE {
?actor p:P569/psv:P569 ?birth_date_node .
{?birth_date_node wikibase:timePrecision "9"^^xsd:integer .}
UNION
{?birth_date_node wikibase:timePrecision "10"^^xsd:integer .}
UNION
{?birth_date_node wikibase:timePrecision "11"^^xsd:integer .}
?birth_date_node wikibase:timeValue ?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) .
BIND(if(?genre=wd:Q6581072,1,0) as ?countfemale)
BIND(if(?genre=wd:Q6581097,1,0) as ?countmale)
FILTER(?age > 0) .
FILTER(?age < 100) .
}
GROUP BY ?age
ORDER BY ?age
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v2("?actor")
v8("?age"):::projected
v3("?birth_date_node")
v8("?countfemale"):::projected
v9("?countmale"):::projected
v7("?dateMovie")
v4("?dob")
v11("?female")
v5("?genre")
v10("?male")
v6("?movie")
a1((" "))
c8(["11^^xsd:integer"]):::literal
c6(["9^^xsd:integer"]):::literal
c12(["wd:Q33999"]):::iri
c7(["10^^xsd:integer"]):::literal
c14(["wd:Q142"]):::iri
f0[["?age < '100^^xsd:integer'"]]
f0 --> v8
f1[["?age > '0^^xsd:integer'"]]
f1 --> v8
v2 --"p:P569"--> a1
a1 --"p:statement/value/P569"--> v3
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
subgraph union1[" Union "]
subgraph union1l[" "]
style union1l fill:#abf,stroke-dasharray: 3 3;
v3 --"wikibase:timePrecision"--> c8
end
subgraph union1r[" "]
style union1r fill:#abf,stroke-dasharray: 3 3;
v3 --"wikibase:timePrecision"--> c7
end
union1r <== or ==> union1l
end
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v3 --"wikibase:timePrecision"--> c6
end
union0r <== or ==> union0l
end
v3 --"wikibase:timeValue"--> v4
v2 --"p:direct/P21"--> v5
v2 --"p:direct/P106"--> c12
v2 --"p:direct/P27"--> c14
v6 --"p:direct/P161"--> v2
v6 --"p:direct/P577"--> v7
bind2[/"year-from-dateTime(?dateMovie) - year-from-dateTime(?dob)"/]
v7 --o bind2
v4 --o bind2
bind2 --as--o v8
bind3[/"if(?genre = 'wd:Q6581072','1^^xsd:integer','0^^xsd:integer')"/]
v5 --o bind3
bind3 --as--o v8
bind4[/"if(?genre = 'wd:Q6581097','1^^xsd:integer','0^^xsd:integer')"/]
v5 --o bind4
bind4 --as--o v9
bind7[/"sum(?countmale)"/]
v9 --o bind7
bind7 --as--o v10
bind8[/"sum(?countfemale)"/]
v8 --o bind8
bind8 --as--o v11