query-b4fed8a178f65bbd34828da21c41a664

rq turtle/ttl

What am I doing wrong? - scatterplotHello, I am trying to plot average weight and height of sportspeople by sport.

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/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#defaultView:ScatterChart
select * where {

   {
  select distinct ?sport ((avg(?height)) as ?avg_height) ((avg(?weight)) as ?avg_weight) where {
   {
    select distinct * where 
     {
    ?item wdt:P1447 [] .
     } 
  }  ?item wdt:P641 ?sport .
  ?item p:P2048/psv:P2048 [
    wikibase:quantityAmount ?baseHeight;
    wikibase:quantityUnit [
      p:P2370/psv:P2370 [
        wikibase:quantityAmount ?unitHeight;
        wikibase:quantityUnit wd:Q11573
      ]
    ]
  ].     
  BIND(?baseHeight * ?unitHeight AS ?height).

  ?item p:P2067/psv:P2067 [
  wikibase:quantityAmount ?baseWeight;
  wikibase:quantityUnit [
      p:P2370/psv:P2370 [
        wikibase:quantityAmount ?unitWeight;
        wikibase:quantityUnit wd:Q11570
      ]
    ]
  ].     
  BIND(?baseWeight * ?unitWeight AS ?weight).
  } group by ?sport }  #SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }

}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v9("?avg_height"):::projected v10("?avg_weight"):::projected v3("?baseHeight") v6("?baseWeight") v5("?height") v1("?item") v2("?sport"):::projected v4("?unitHeight") v7("?unitWeight") v8("?weight") a1((" ")) a6((" ")) a2((" ")) a4((" ")) a5((" ")) a3((" ")) a11((" ")) a7((" ")) a9((" ")) a10((" ")) a8((" ")) c5(["wd:Q11573"]):::iri c10(["wd:Q11570"]):::iri v1 --"p:direct/P1447"--> a1 v1 --"p:direct/P641"--> v2 a2 --"wikibase:quantityAmount"--> v3 a3 --"wikibase:quantityAmount"--> v4 a3 --"wikibase:quantityUnit"--> c5 a4 --"p:P2370"--> a5 a5 --"p:statement/value/P2370"--> a3 a2 --"wikibase:quantityUnit"--> a4 v1 --"p:P2048"--> a6 a6 --"p:statement/value/P2048"--> a2 bind0[/"?baseHeight * ?unitHeight"/] v3 --o bind0 v4 --o bind0 bind0 --as--o v5 a7 --"wikibase:quantityAmount"--> v6 a8 --"wikibase:quantityAmount"--> v7 a8 --"wikibase:quantityUnit"--> c10 a9 --"p:P2370"--> a10 a10 --"p:statement/value/P2370"--> a8 a7 --"wikibase:quantityUnit"--> a9 v1 --"p:P2067"--> a11 a11 --"p:statement/value/P2067"--> a7 bind1[/"?baseWeight * ?unitWeight"/] v6 --o bind1 v7 --o bind1 bind1 --as--o v8 bind4[/"average(?height)"/] v5 --o bind4 bind4 --as--o v9 bind5[/"average(?weight)"/] v8 --o bind5 bind5 --as--o v10