an XQuery query that calculates the average of the grades of each course, how i can do?
<?xml-stylesheet href="class3.xsl" type="text/xsl" ?><school>
<student><name>Jack T</name>
<course title="INF8430" note="78"/>
<course title="INF1030" note="69"/>
<course title="INF1230" note="85"/></student>
<student><name>Marty L</name>
<course title="INF8430" note="95"/>
<course title="INF1030" note="82"/>
<course title="INF1230" note="77"/></student>
<student><name>Ben L</name>
<course title="INF9430" note="59"/>
<course title="INF1030" note="78"/>
<course title="INF1230" note="79"/></student>
</school>
i do this but dnst work:
for $s in distinct-values(doc("tesst.xml")//course/@title)
return
avg(doc("tesst.xml")//course[@title=$s]/@note)
<course title="{$s},"></course>
to get this:
<maliste>
<cours sigle="INF8430">85</cours>
<cours sigle="INF1030">76.66666666666667</cours>
<cours sigle="INF1230">81.5</cours>
<cours sigle="INF9430">39</cours>
</maliste>
an XQuery query that calculates the average of the grades of each course, how i can do?