i need to select the top 3 Average scores from a table of scores with many columns, i tried this query
SELECT StudentID,
classid,sessionid,termid,classlevelid,
ROUND( avg( total ) , 2 ) ave
FROM ResultView r1
where sessionid=4 and termid=1
GROUP BY StudentID,classid
ORDER BY 3 DESC, 2 asc;
which gave
StudentID|classid|sessionid|termid|classlevelid|ave
---------+-------+---------+------+------------+------
5 |8 |4 |1 |1 |56.81
6 |8 |4 |1 |1 |58.38
7 |8 |4 |1 |1 |56.13
2 |10 |4 |1 |2 |68.0
3 |10 |4 |1 |2 |72.8
4 |10 |4 |1 |2 |73.2
5 |10 |4 |1 |2 |70.2
As you can see, its getting more that 3 for each classlevelid, how do i make it get only the top 3 average for each classlevelid?
Aucun commentaire:
Enregistrer un commentaire