create cursor curAbsentees (StudentID, Absences I) select myTable set order to StudentID lnAbsences = 0 lcStudentID = "" scan if not m.lcStudentID = StudentID if m.lnAbsences >=5 insert into curAbsentees values (m.lcStudentID, m.lnAbsences) endif lnAbsences = 0 lcStudentID = StudentID endif if Category = 'A' lnAbsences = m.lnAbsences + 1 endif if Category <> 'A' lnAbsences = 0 endif endscanFrom the top of my head and not tested. Somehow I always forget the technique to process the last user as well. In my case you would need to add some post-processing code after the loop, e.g.
if m.lnAbsences >=5 && Last StudentID insert into ... endif