The $elemMatch cannot be used within the $expr, as $expr takes only the aggregate operators as arguments.
However, my question is how do I compare the score for the two types of entries (ie type: “exam” and type: “quiz”) so that I filter only “exam” scores which are greater than “quiz” scores for the same student. Help and feedback is much appreciated
@Prasad_Saya , I appreciate the help. After pondering on the idea of using some arrays operators I have finally found the solution in the $slice operator. The query below gave me the results I expected! It is amazing!! Thank you