Sele 1 use horse Sele 2 use rescjc index on horsename to rescomm use rescjc index rescomm Sele 3 use resfjc zap store 0 to krnum,khnum Sele 1 Do while .not. eof() mrnum = rnum mhnum = hnum mh_name = horsename Sele 2 Seek mh_name Do while mh_name = horsename .and. .not. eof() mh_namec = h_namec mracedate = racedate mpnum = rnum mcom_jc = com_jc mfn = fn Sele 3 append blank if mrnum > krnum repl rnum with mrnum endif if mhnum <> khnum repl hnum with mhnum repl h_namec with mh_namec endif repl racedate with mracedate repl pnum with mpnum repl com_jc with mcom_jc repl fn with mfn Sele 2 Skip khnum = mhnum kh_name = mh_name Enddo krnum = mrnum Sele 1 Skip Enddo close all database