query-43a37b3d49d388ced393be250508158a

rq turtle/ttl

TagishsimonLarske(Q3037216)Dorothée Jemma (Q33999)actor (Q11481802)dub actor

Use at

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 [ wikibase:timePrecision ?tp; wikibase:timeValue ?dob ]. 
  FILTER(?tp>8) 
  ?actor wdt:P21 ?genre .
  {
    SELECT distinct ?actor WHERE {
        ?actor wdt:P106/wdt:P279* wd:Q33999 .   #include subclasses of "actors" such as "child actors"
      }
    }
  ?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; v4("?actor") v8("?age"):::projected v8("?countfemale"):::projected v9("?countmale"):::projected v7("?dateMovie") v3("?dob") v11("?female") v5("?genre") v10("?male") v6("?movie") v2("?tp") a2((" ")) a1((" ")) a3((" ")) c11(["wd:Q33999"]):::iri c13(["wd:Q142"]):::iri f0[["?age < '100^^xsd:integer'"]] f0 --> v8 f1[["?age > '0^^xsd:integer'"]] f1 --> v8 f2[["?tp > '8^^xsd:integer'"]] f2 --> v2 a1 --"wikibase:timePrecision"--> v2 a1 --"wikibase:timeValue"--> v3 v4 --"p:P569"--> a2 a2 --"p:statement/value/P569"--> a1 v4 --"p:direct/P21"--> v5 v4 --"p:direct/P106"--> a3 a3 --"p:direct/P279"--> c11 v4 --"p:direct/P27"--> c13 v6 --"p:direct/P161"--> v4 v6 --"p:direct/P577"--> v7 bind3[/"year-from-dateTime(?dateMovie) - year-from-dateTime(?dob)"/] v7 --o bind3 v3 --o bind3 bind3 --as--o v8 bind4[/"if(?genre = 'wd:Q6581072','1^^xsd:integer','0^^xsd:integer')"/] v5 --o bind4 bind4 --as--o v8 bind5[/"if(?genre = 'wd:Q6581097','1^^xsd:integer','0^^xsd:integer')"/] v5 --o bind5 bind5 --as--o v9 bind8[/"sum(?countmale)"/] v9 --o bind8 bind8 --as--o v10 bind9[/"sum(?countfemale)"/] v8 --o bind9 bind9 --as--o v11