Get Students With Highest Average Score Using MongoDB & EsProc SPL
Computing highest average score in MongoDB: unwind Scores, group by StudentID, calculate avg_score, sort & get top records. esProc SPL also simplifies this task with a single script.
The following collection contains a list table of nested structure. One computing scenario is to compute values in the list table and get records containing the largest value. Below is scores collection that stores student scores of a number of subjects. We are trying to get students obtaining the highest average score. { "StudentID":"S0001", "Scores":[{"Course":"Chinese","Score":75},{"Course":"Maths","Score":81}, {"Course":"English","Score":78}] } { "StudentID":"S0002", "Scores":[{"Course":"Chinese","Score":80},{"Course":"Maths","Scor...