>Have a free table that has duplicates on field1 and field2. I want to sort on field1,field2,field3 and remove all but the last duplicate from field1,field2.
>
>example. want to sort on lastname, firstname, add_date. if the lastname, firstname are duplciates want to keep only the one with the highest add_date.
>
>Can anyone help. thanks
>
>brenda
This is just a WAG off the top of my head:
select keyid, lastname+firstname customer, count(lastname+firstname), max(add_date) from mytable group by 2 having count(lastname+firstname) > 1 into cursor crsTemp
delete from mytable where keyid in (select keyid from crsTemp)
Of course, test on a copy of the table.
Mark McCasland
Midlothian, TX USA