Afi83 0 Light Poster

Hi there

I want to search a records in course filed and find the names that repeated in records. For example if math repeated 3 times I want to show only the maximum of the grades in grades field for person and don't consider others.
I do something like this, but I can't do it as described above.
'Here is the basic syntax

if {course.courseName}=next({course.courseName}) then 
formula={grades.grade}
end if

What I have to do for solving this;