query-6f2f1e26b4fe83d856c9e8c0a3f60cc2

rq turtle/ttl

Propertiesinstance of (P31)subclass of (P279)minimum age (P2899)

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?rating (round(avg(?dif)*1000)/1000 AS ?average) (count(?dif) AS ?total) (round(avg(?count)*10)/10 AS ?count)
WHERE {
   {
  SELECT ?film (avg(?age0) as ?age) ?rating
  WHERE {
    [] wdt:P31/wdt:P279* wd:Q24716199; wikibase:directClaim ?p; rdfs:label ?rating FILTER(lang(?rating)="en") .
    ?film wdt:P31/wdt:P279* wd:Q11424; ?p [ wdt:P2899 ?age0 ] .
  } GROUP BY ?film ?rating
}  {
    SELECT ?film (avg(?age) AS ?avg) (count(?rating)-1 as ?count)
    WHERE {
       {
  SELECT ?film (avg(?age0) as ?age) ?rating
  WHERE {
    [] wdt:P31/wdt:P279* wd:Q24716199; wikibase:directClaim ?p; rdfs:label ?rating FILTER(lang(?rating)="en") .
    ?film wdt:P31/wdt:P279* wd:Q11424; ?p [ wdt:P2899 ?age0 ] .
  } GROUP BY ?film ?rating
}    } GROUP BY ?film HAVING (?count > 0)
  } 
  BIND (?age-?avg AS ?dif)
} GROUP BY ?rating

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v7("?_anon_d00291b7e9a143df8ec0be8c8ebd714c7022") v10("?_anon_d00291b7e9a143df8ec0be8c8ebd714c7023"):::projected v11("?_anon_d00291b7e9a143df8ec0be8c8ebd714c7024"):::projected v7("?age") v4("?age0") v12("?average") v8("?avg") v14("?count") v9("?dif"):::projected v3("?film") v2("?p") v1("?rating"):::projected v13("?total") a1((" ")) a5((" ")) a2((" ")) a3((" ")) a4((" ")) a6((" ")) a7((" ")) a8((" ")) c4(["wd:Q24716199"]):::iri c7(["wd:Q11424"]):::iri f0[["?rating = 'en'"]] f0 --> v1 a1 --"wdt:P31"--> a2 a2 --"wdt:P279"--> c4 a1 --"wikibase:directClaim"--> v2 a1 --"rdfs:label"--> v1 v3 --"wdt:P31"--> a3 a3 --"wdt:P279"--> c7 a4 --"wdt:P2899"--> v4 v3 -->v2--> a4 bind2[/"average(?age0)"/] v4 --o bind2 bind2 --as--o v7 f3[["?count > '0^^xsd:integer'"]] f3 --> v14 f4[["?rating = 'en'"]] f4 --> v1 a5 --"wdt:P31"--> a6 a6 --"wdt:P279"--> c4 a5 --"wikibase:directClaim"--> v2 a5 --"rdfs:label"--> v1 v3 --"wdt:P31"--> a7 a7 --"wdt:P279"--> c7 a8 --"wdt:P2899"--> v4 v3 -->v2--> a8 bind6[/"average(?age0)"/] v4 --o bind6 bind6 --as--o v7 bind9[/"count(?rating)"/] v1 --o bind9 bind9 --as--o v7 bind10[/"average(?age)"/] v7 --o bind10 bind10 --as--o v8 bind11[/" + '-1^^xsd:integer'"/] null --o bind11 bind11 --as--o v14 bind12[/"?age - ?avg"/] v7 --o bind12 v8 --o bind12 bind12 --as--o v9 bind16[/"average(?dif)"/] v9 --o bind16 bind16 --as--o v10 bind17[/"average(?count)"/] v14 --o bind17 bind17 --as--o v11 bind18[/"numeric-round( * '1000^^xsd:integer') / '1000^^xsd:integer'"/] null --o bind18 bind18 --as--o v12 bind19[/"count(?dif)"/] v9 --o bind19 bind19 --as--o v13 bind20[/"numeric-round( * '10^^xsd:integer') / '10^^xsd:integer'"/] null --o bind20 bind20 --as--o v14