>ID Name Year No >1 Khubaib 2005 5 >1 Khubaib 2006 6 >1 Khubaib 2007 7>
>id name (year)no (year)no > >1 khubaib 5 6Khubaib,
create cursor curFinal (ID I, Name C(20), No1 I, No2 I) select * from myTable into cursor curTemp nofilter order by ID, Year index on str(ID) + str(Year,4) set exact off select distinct ID from curTemp into cursor curIDs order by 1 select curIDs scan select curTemp =seek(str(curIDs.ID)) && I assume it would be the first record in the index sequence insert into curFinal values (curTemp.ID, curTemp.Name, curTemp.No) if not eof('curTemp') skip if not eof('curTemp') and curTemp.ID = curIDs.ID replace No2 with curTemp.No in curFinal endif endif endscanThis would result in the two lowest years data inserted for each ID.