Saturday, June 7, 2014

What is the student_id of the lowest exam score above 65?

For "What is the student_id of the lowest exam score above 65?"

run the below query you will get the answer

db.grades.aggregate({$group:{_id:{studentId:"$student_id",'typ1':"$type"},'average':{$avg:'$score'}}},{"$sort":{"average":1}},{$match:{"_id.typ1":"exam","average":{$gte:65}}},{"$limit":1});

1 comment: