query-7f859af69ab97c21fc2f6a20eb5e80f1

rq turtle/ttl

number of movie ratings by date of original release SELECT ?year ((round(avg(?age)10)/10) AS ?avg) ((round(sum((?age-?avg)(?age-?avg))100/count(?age))/100) AS ?var) (count(distinct ?film) AS ?films) (count(?age) AS ?ratings) WHERE { { SELECT ?film ?age (year(min(?date)) AS ?year) WHERE { [] wdt:P31/wdt:P279 wd:Q24716199; wikibase:directClaim ?p . ?film wdt:P31/wdt:P279 wd:Q11424; wdt:P577 ?date; ?p [ wdt:P2899 ?age ] . } GROUP BY ?film ?age } { SELECT ?year (avg(?avgf) AS ?avg) WHERE { { SELECT ?film (year(min(?date)) AS ?year) (avg(?age) AS ?avgf) WHERE { [] wdt:P31/wdt:P279 wd:Q24716199; wikibase:directClaim ?p . ?film wdt:P31/wdt:P279* wd:Q11424; wdt:P577 ?date; ?p [ wdt:P2899 ?age ] . } GROUP BY ?film } } GROUP BY ?year } } GROUP BY ?year ORDER BY DESC(?year)

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
#number of movie ratings by date of original release
SELECT ?year ((round(avg(?age)*10)/10) AS ?avg)
       ((round(sum((?age-?avg)*(?age-?avg))*100/count(?age))/100) AS ?var)
       (count(distinct ?film) AS ?films) (count(?age) AS ?ratings)
WHERE {
  { SELECT ?film ?age (year(min(?date)) AS ?year)
    WHERE {
      [] wdt:P31/wdt:P279* wd:Q24716199; wikibase:directClaim ?p .
      ?film wdt:P31/wdt:P279* wd:Q11424; wdt:P577 ?date; ?p [ wdt:P2899 ?age ] .
    } GROUP BY ?film ?age
  }
  { SELECT ?year (avg(?avgf) AS ?avg)
    WHERE {
      { SELECT ?film (year(min(?date)) AS ?year) (avg(?age) AS ?avgf)
        WHERE {
          [] wdt:P31/wdt:P279* wd:Q24716199; wikibase:directClaim ?p .
          ?film wdt:P31/wdt:P279* wd:Q11424; wdt:P577 ?date; ?p [ wdt:P2899 ?age ] .
        } GROUP BY ?film
      }
    } GROUP BY ?year
  }
} GROUP BY ?year ORDER BY DESC(?year)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v6("?_anon_42b5416610844a34809f33a099ae9de1139185") v7("?_anon_42b5416610844a34809f33a099ae9de1139194") v5("?age"):::projected v10("?avg") v8("?avgf") v4("?date") v3("?film"):::projected v11("?films") v2("?p") v12("?ratings") v10("?var") v8("?year"):::projected a1((" ")) a5((" ")) a2((" ")) a3((" ")) a4((" ")) a6((" ")) a7((" ")) a8((" ")) c3(["wd:Q24716199"]):::iri c5(["wd:Q11424"]):::iri a1 --"wdt:P31"--> a2 a2 --"wdt:P279"--> c3 a1 --"wikibase:directClaim"--> v2 v3 --"wdt:P31"--> a3 a3 --"wdt:P279"--> c5 v3 --"wdt:P577"--> v4 a4 --"wdt:P2899"--> v5 v3 -->v2--> a4 bind1[/"min(?date)"/] v4 --o bind1 bind1 --as--o v6 bind2[/"year-from-dateTime()"/] null --o bind2 bind2 --as--o v8 a5 --"wdt:P31"--> a6 a6 --"wdt:P279"--> c3 a5 --"wikibase:directClaim"--> v2 v3 --"wdt:P31"--> a7 a7 --"wdt:P279"--> c5 v3 --"wdt:P577"--> v4 a8 --"wdt:P2899"--> v5 v3 -->v2--> a8 bind5[/"min(?date)"/] v4 --o bind5 bind5 --as--o v7 bind6[/"year-from-dateTime()"/] null --o bind6 bind6 --as--o v8 bind7[/"average(?age)"/] v5 --o bind7 bind7 --as--o v8 bind9[/"average(?avgf)"/] v8 --o bind9 bind9 --as--o v10 bind15[/"numeric-round( * '10^^xsd:integer') / '10^^xsd:integer'"/] null --o bind15 bind15 --as--o v10 bind16[/"numeric-round( * '100^^xsd:integer' / ) / '100^^xsd:integer'"/] null --o bind16 null --o bind16 bind16 --as--o v10 bind17[/"count(?film)"/] v3 --o bind17 bind17 --as--o v11 bind18[/"count(?age)"/] v5 --o bind18 bind18 --as--o v12